Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open('input.txt', 'r')
- line = f.readlines()[1]
- f.close()
- n, k = -1, 0
- c = 1
- count = 0
- for i in range(len(line) - 1, -1, -1):
- n += 1
- if line[i] == '1':
- k += 1
- if n < k:
- continue
- if (line[i] == '1') and (k > 0):
- c = c * n // k
- count += c
- elif n > k:
- c = c * n // (n - k)
- f = open('output.txt', 'w')
- f.write(bin(count)[2:])
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement