Advertisement
Guest User

fma

a guest
Feb 17th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. def solve(N, K, V):
  4.   solution = 0
  5.   # Write your solution here
  6.  
  7.   for i in range(N+1):
  8.     val=0
  9.     for j in range(N+1):
  10.       if (j!=i):
  11.         val+=V[j]*(2**j)
  12.       j+=1
  13.     for k in range (-K,K+1):
  14.       if (val+k*2**i)==0: solution+=1
  15.  
  16.   return solution
  17.  
  18. if __name__ == "__main__":
  19.   N, K = map(int, input().strip().split(" "))
  20.   V = list(map(int, input().strip().split(" ")))
  21.   print(solve(N, K, V))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement