암호를 찾으면 7자리씩 decoding하고 배열에 저장해 유효성 판단하고 값을 반환합니다.
따로 알고리즘이 필요한 문제는 아닙니다.
for test in range(1, int(input()) + 1):
N, M = map(int, input().split())
nums = {'0001101': 0, '0011001': 1, '0010011': 2, '0111101': 3, '0100011': 4, '0110001': 5, '0101111': 6, '0111011': 7, '0110111': 8, '0001011': 9}
bits = []
for _ in range(N):
a = input()
idx = 0
if bits: continue
while idx < M - 7:
idx += 1
if a[idx:idx+7] in nums and not int(a[idx + 7]):
bits.append(nums[a[idx:idx+7]])
idx += 6
answer = sum(bits) if not (sum(bits) + 2 * sum(bits[0:7:2])) % 10 else 0
print(f'#{test} {answer}')
'practivceAlgorithm > swexpertacademy' 카테고리의 다른 글
[SWEA][Python] 1244 최대상금 (0) | 2021.10.01 |
---|---|
[SWEA][Python] 10726 이진수 표현 (0) | 2021.10.01 |
[SWEA][Python] 5203 베이비진 게임 (0) | 2021.09.28 |
[SWEA][Python] 5202 화물도크 (0) | 2021.09.28 |
[SWEA][Python] 5201 컨테이너 운반 (0) | 2021.09.28 |