Skip to content

Instantly share code, notes, and snippets.

@wkentaro
Last active August 29, 2015 14:08
Show Gist options
  • Save wkentaro/cfbbafea4cc6f6b483d4 to your computer and use it in GitHub Desktop.
Save wkentaro/cfbbafea4cc6f6b483d4 to your computer and use it in GitHub Desktop.
20141026 atcoder sample
a = int(raw_input())
n_snacks = a
n_students = int(raw_input())
while (n_snacks % n_students) != 0:
n_snacks += 1
print (n_snacks - a)
n, X = raw_input().split(' ')
n, X = map(int, [n, X])
a = raw_input().split(' ')
a = map(int, a)
flags = format(X, '0'+str(n)+'b')
sum = 0
for i, flg in enumerate(flags):
if flg == '1':
sum += a[len(a)-1-i]
print sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment