Coding/백준 온라인 저지 (Baekjoon Online Judge)
백준 온라인 저지(Baekjoon Online Judge) - 5220 : Error Detection
_Woo_
2023. 5. 10. 05:43
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")