The most interesting problem by now!
Solution:
Code:
from __future__ import division
import sys
import math
from scipy import special
def main():
if len(sys.argv) > 2:
k = int(sys.argv[1])
N = int(sys.argv[2])
descend_num = pow(2, k)
i = N
prob = 0
while i <= descend_num:
p = descend_num - i
prob = prob + special.binom(descend_num, i)*pow(1/4, i)*pow(3/4, p)
i += 1
print round(prob, 3)
else:
print 'Enter data!'
if __name__ == '__main__':
main()
Solution:
Code:
from __future__ import division
import sys
import math
from scipy import special
def main():
if len(sys.argv) > 2:
k = int(sys.argv[1])
N = int(sys.argv[2])
descend_num = pow(2, k)
i = N
prob = 0
while i <= descend_num:
p = descend_num - i
prob = prob + special.binom(descend_num, i)*pow(1/4, i)*pow(3/4, p)
i += 1
print round(prob, 3)
else:
print 'Enter data!'
if __name__ == '__main__':
main()
Комментариев нет:
Отправить комментарий