https://www.acmicpc.net/problem/5220
5220번: Error Detection
In the midst of a fierce battle, Tony Stark’s suit constantly communicates with JARVIS for technical data. This data as transmitted takes the form of 16-bit integer values. However, due to various atmospheric issues (such as those created by all of that
www.acmicpc.net
def count_ones(n):
count = 0
while n:
count += n & 1
n >>= 1
return count
t = int(input())
for _ in range(t):
n, check_bit = map(int, input().split())
ones_count = count_ones(n)
if check_bit == 1 and ones_count % 2 == 0:
print("Corrupt")
elif check_bit == 0 and ones_count % 2 == 1:
print("Corrupt")
else:
print("Valid")
'Coding > 백준 온라인 저지 (Baekjoon Online Judge)' 카테고리의 다른 글
백준 온라인 저지(Baekjoon Online Judge) - 9095 : 1, 2, 3 더하기 (0) | 2023.05.10 |
---|---|
백준 온라인 저지(Baekjoon Online Judge) - 9063 : 대지 (0) | 2023.05.10 |
백준 온라인 저지(Baekjoon Online Judge) - 2774 : 아름다운 수 (0) | 2023.05.10 |
백준 온라인 저지(Baekjoon Online Judge) - 2789 : 유학 금지 (0) | 2023.05.10 |
백준 온라인 저지(Baekjoon Online Judge) - 10101 : 삼각형 외우기 (0) | 2023.05.10 |