Advertisement
NLinker

task-113316.py

Jul 25th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. def parse_args():
  2.     nk = list(map(int, input().split(' ')))
  3.     return nk[0], nk[1]
  4.  
  5.  
  6. def modify(arr, tmp, n):
  7.     for i in range(0, n):
  8.         if arr[i]:
  9.             ip = (i + 1) % n
  10.             im = (i + n - 1) % n
  11.             tmp[ip] = 1
  12.             tmp[im] = 1
  13.     for i in range(0, n):
  14.         arr[i] = tmp[i]
  15.         tmp[i] = 0
  16.     return arr
  17.  
  18. if __name__ == "__main__":
  19.     n, k = parse_args()
  20.     arr = [1] + [0] * (n - 1)
  21.     tmp = [0] * n
  22.     for k in range(0, k):
  23.         # print(list(map(int, arr)))
  24.         arr = modify(arr, tmp, n)
  25.     # print(list(map(int, brr)))
  26.     m = sum(map(int, arr))
  27.     print(m)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement