题解 | 牛牛的10类人

牛牛的10类人

https://www.nowcoder.com/practice/232b7fc32fac4636819e31a7d7c960a3

n = int(input())
l = list(map(int, input().split()))
s = []
for i in l:
    x = ''
    while i > 0:
        y = i % 2
        i = i // 2
        x = x + str(y)
    x = x[::-1]
    shu1 = 0
    shu0 = 0
    for j in x:
        if j == '1':
            shu1 += 1
        elif j == '0':
            shu0 += 1
    if shu1 % 2 == 0 and shu0 % 2 ==0 and shu1 != 0 and shu0 != 0:
        s.append(10)
    elif shu1 % 2 == 0 and shu1 != 0:
        s.append(1)
    elif shu0 % 2 == 0 and shu0 != 0:
        s.append(0)
    else:
        s.append(100)
print(' '.join(map(str, s)))

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务