본문 바로가기
problem solving

1946. 간단한 압축 풀기

by ormgm 2019. 9. 13.

t = int(input())

 

for p in range(t):

    n = int(input())

    char = 0

    num = 0

    sw = 0

    strr = ''

    left_num = 0

    print('#%d' % (p + 1))

    for q in range(n):

        char,num = map(str,input().split())

        num = int(num)

 

        if sw + num == 10:

            sw = sw + num

            strr = strr + (char * num)

            print(strr)

            sw = 0

            strr = ''

        elif sw + num < 10:

            sw = sw + num

            strr = strr + (char * num)

            if q == n - 1:

                print(strr)

 

        elif sw + num > 10:

            left_num = num - (10 - sw)

            num = 10-sw

            sw = sw + num

            strr = strr + (char * num)

            print(strr)

 

            if left_num > 10:

                strr = char * 10

                print(strr)

                left_num = left_num - (left_num - 10)

                strr = char * left_num

                sw = left_num

            else:

                sw = left_num

                strr = ''

                strr = strr + (char * left_num)

 

            if q == n - 1:

                print(strr)

            if left_num == 10:

                print(strr)

                strr = ''

                left_num = 0

                sw = 0

                num = 0

'problem solving' 카테고리의 다른 글

1940. 가랏! RC카!  (0) 2019.09.14
1945. 간단한 소인수분해  (0) 2019.09.13
1948. 날짜 계산기  (0) 2019.09.13
1954. 달팽이 숫자  (0) 2019.09.12
1959. 두 개의 숫자열  (0) 2019.09.12

댓글