[SWEA] 단순 2진 암호코드

Date:

[SWEA] 단순 2진 암호코드

Problem URL : 단순 2진 암호코드

import sys
sys.stdin = open("input.txt")

code = {"0001101":0, "0011001":1, "0010011":2, "0111101":3, "0100011":4, "0110001":5, "0101111":6, "0111011":7, "0110111":8, "0001011":9}

TC = int(input())

for tc in range(1, TC + 1):
    r, c = map(int, input().split())
    info = [input() for _ in range(r)]
    x = 0
    y = 0
    breakCheck = False
    for i in range(r):
        for j in range(c-1, -1, -1):
            if info[i][j] == '1':
                x = i
                y = j - 55
                breakCheck = True
                break
        if breakCheck:
            break
    check = 0
    sum = 0
    for idx in range(y,y+56,7):
        tmp = info[x][idx:idx+7]
        if tmp in code:
            sum += code[tmp]
            if (idx-y) % 14 == 0:
                check += code[tmp] * 3
            else:
                check += code[tmp]
        else:
            sum = 0

    if check % 10 != 0:
        sum = 0

    print("#{} {}".format(tc, sum))

Comments

간단한 문자열 문제
문제 풀기보다 문제 이해하기가 더 귀찮은 문제이다…

댓글