본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 12782번 비트 우정지수

by 현장 2022. 5. 8.

-Code

for _ in range(int(input())):
    n, m = input().split()
    a = int(n, 2)
    b = int(m, 2)
    and_answer = bin(a & b)[2:]
    n_cnt = n.count('1')
    m_cnt = m.count('1')
    answer_cnt = and_answer.count('1')
    print(max(n_cnt - answer_cnt, m_cnt - answer_cnt))