Advertisement
DanilaG

Untitled

Dec 20th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. inF = open('input.txt', 'r')
  2. outF = open('output.txt', 'w')
  3. s = inF.read().split()
  4. n = int(s[0])
  5. m = int(s[1])
  6. s = s[2]
  7.  
  8. N = [0, 0]
  9. res = 0
  10.  
  11. c = 1
  12. was0 = False
  13. for i in range(m + n - 1, 0 - 1, -1):
  14.     N[int(s[i])] += 1
  15.     if s[i] == '0':
  16.         was0 = True
  17.         if ((N[0] + N[1] - 1) - N[1]):
  18.             c = ((c * (N[0] + N[1] - 1)) // ((N[0] + N[1] - 1) - N[1]))
  19.         continue
  20.     if (was0):
  21.         c = ((c * (N[0] + N[1] - 1)) // N[1])
  22.         res += c
  23. print(str(bin(res))[2:], file = outF)
  24. inF.close()
  25. outF.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement