Last active
August 29, 2015 14:08
-
-
Save wkentaro/cfbbafea4cc6f6b483d4 to your computer and use it in GitHub Desktop.
20141026 atcoder sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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