Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inF = open('input.txt', 'r')
- outF = open('output.txt', 'w')
- s = inF.read().split()
- n = int(s[0])
- m = int(s[1])
- s = s[2]
- N = [0, 0]
- res = 0
- c = 1
- was0 = False
- for i in range(m + n - 1, 0 - 1, -1):
- N[int(s[i])] += 1
- if s[i] == '0':
- was0 = True
- if ((N[0] + N[1] - 1) - N[1]):
- c = ((c * (N[0] + N[1] - 1)) // ((N[0] + N[1] - 1) - N[1]))
- continue
- if (was0):
- c = ((c * (N[0] + N[1] - 1)) // N[1])
- res += c
- print(str(bin(res))[2:], file = outF)
- inF.close()
- outF.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement