Submission #251590

# Submission time Handle Problem Language Result Execution time Memory
251590 2020-07-21T21:49:32 Z Bruteforceman Popcount (COCI19_popcount) Python 3
0 / 110
27 ms 3436 KB
import math
import sys
n, k = map(int, input().split())
def value(a) :
    ans = 0
    for i in range(len(a)):
        if a[i] == 1:
            ans += 1 << i
    return str(ans)
a = [(i, i) for i in range(n)]
sz = 1
while len(a) > 0: 
    s = [0] * n
    t = [0] * n
    b = []
    for i in range(1, len(a), 2):
        for j in range(a[i - 1][0], a[i - 1][1] + 1):
            s[j] = 1
        for j in range(a[i][0], a[i][1] + 1):
            t[j] = 1
        b.append((a[i - 1][0], a[i][1]))
    exp = '((A&' + value(s) + ')+((A&' + value(t) + ')>>' + str(sz) + '))'
    if len(a) % 2 == 1:
        s = [0] * n
        t = [0] * n
        for j in range(a[-1][0], a[-1][1] + 1):
            s[j] = 1
        for j in range(a[-1][1] + 1, n):
            t[j] = 1
        extra = '((A&' + value(s) + ')+((A&' + value(t) + ')>>' + str(sz) + '))'
        exp = '(' + exp + '|' + extra + ')'
    print('A=' + exp)
    a = b[:]
    sz *= 2
        

# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3428 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3428 KB Wrong output format.
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 3428 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 3436 KB Wrong output format.
2 Halted 0 ms 0 KB -