본문 바로가기
python-algorithm

백준 5220 Error Detection

by 무적김두칠 2023. 1. 4.

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

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def cal(n):
    if bin(n)[2:].count('1') % 2:
        return 1
    else:
        return 0
 
 
def sol(n, bit):
    if cal(n) == bit:
        return 'Valid'
    else:
        return 'Corrupt'
 
 
if __name__ == '__main__':
    for _ in range(int(input())):
        n, bit = map(int, input().split())
        print(sol(n, bit))
 
cs

패리티 비트 찾는 문제죵
This is to find Parity bits

반응형

'python-algorithm' 카테고리의 다른 글

leetcode 2469. Convert the Temperature  (0) 2023.01.06
백준 10420 기념일 1  (0) 2023.01.04
백준 16316 Baby Bites  (0) 2023.01.04
백준 6190 Another Cow Number Game  (0) 2023.01.03
백준 16861 Harshad Numbers  (0) 2023.01.03

댓글