Submission #258415

# Submission time Handle Problem Language Result Execution time Memory
258415 2020-08-05T22:54:39 Z ipaljak Popcount (COCI19_popcount) Python 3
110 / 110
32 ms 3360 KB
#!/usr/bin/python3

def main():
    n, k = map(int, input().split())
    code = []
    i = 0
    while (1 << i) < n:
        p = (1 << (1 << i)) - 1
        while p < (1 << n):
            p = p << (1 << (i + 1)) | ((1 << (1 << i)) - 1)
        p &= (1 << n) - 1
        q = ((1 << (1 << i)) - 1) << (1 << i)
        while q < (1 << n):
            q = q << (1 << (i + 1)) | ((1 << (1 << i)) - 1) << (1 << i)
        q &= (1 << n) - 1
        code.append("A=((A&" + str(p) + ")+((A&" + str(q) + ")>>(1<<" + str(i) + ")))")
        i += 1

    print(len(code))
    for line in code:
        print(line)


if __name__ == '__main__':
    main()
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3308 KB Accepted.
2 Correct 20 ms 3300 KB Accepted.
3 Correct 22 ms 3300 KB Accepted.
4 Correct 20 ms 3308 KB Accepted.
5 Correct 22 ms 3308 KB Accepted.
6 Correct 20 ms 3304 KB Accepted.
7 Correct 22 ms 3308 KB Accepted.
8 Correct 25 ms 3308 KB Accepted.
9 Correct 22 ms 3336 KB Accepted.
10 Correct 22 ms 3324 KB Accepted.
11 Correct 21 ms 3300 KB Accepted.
12 Correct 24 ms 3300 KB Accepted.
13 Correct 23 ms 3308 KB Accepted.
14 Correct 20 ms 3308 KB Accepted.
# Verdict Execution time Memory Grader output
1 Correct 24 ms 3328 KB Accepted.
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3300 KB Accepted.
2 Correct 20 ms 3300 KB Accepted.
3 Correct 21 ms 3360 KB Accepted.
4 Correct 19 ms 3308 KB Accepted.
5 Correct 21 ms 3300 KB Accepted.
6 Correct 20 ms 3308 KB Accepted.
7 Correct 20 ms 3308 KB Accepted.
8 Correct 20 ms 3308 KB Accepted.
9 Correct 21 ms 3308 KB Accepted.
10 Correct 20 ms 3300 KB Accepted.
11 Correct 20 ms 3308 KB Accepted.
12 Correct 20 ms 3308 KB Accepted.
13 Correct 20 ms 3300 KB Accepted.
14 Correct 22 ms 3360 KB Accepted.
15 Correct 24 ms 3300 KB Accepted.
16 Correct 21 ms 3308 KB Accepted.
17 Correct 21 ms 3308 KB Accepted.
18 Correct 23 ms 3292 KB Accepted.
19 Correct 21 ms 3308 KB Accepted.
20 Correct 22 ms 3300 KB Accepted.
21 Correct 20 ms 3308 KB Accepted.
# Verdict Execution time Memory Grader output
1 Correct 20 ms 3308 KB Accepted.
2 Correct 20 ms 3308 KB Accepted.
3 Correct 21 ms 3308 KB Accepted.
4 Correct 21 ms 3336 KB Accepted.
5 Correct 25 ms 3308 KB Accepted.
6 Correct 20 ms 3308 KB Accepted.
7 Correct 32 ms 3308 KB Accepted.
8 Correct 21 ms 3308 KB Accepted.
9 Correct 21 ms 3308 KB Accepted.
10 Correct 21 ms 3300 KB Accepted.
11 Correct 21 ms 3308 KB Accepted.
12 Correct 21 ms 3328 KB Accepted.