본문 바로가기
Algorithm

[구현] 백준 17010 Time to Decompress - 파이썬(Python)

by jangThang 2022. 12. 9.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    17010번: Time to Decompress

    The output should be L lines long. Each line should contain the decoding of the corresponding line of the input. Specifically, if line i+1 of the input contained N x, then line i of the output should contain just the character x printed N times.

    www.acmicpc.net

     

     

     

    2. 문제 풀이

     문자열과 문자열을 반복 출력할 횟수가 주어집니다. 반복 횟수만큼 문자열을 출력해야 합니다.

     

     

     

    3. 코드

    # 입력
    T = int(input())
    for _ in range(T):
        N, char = input().split()
        print(char*int(N))

     파이썬에서는 문자열과 정수의 연산으로 문자열을 반복할 수 있습니다. 이 특성을 이용하면 반복문 없이도 쉽게 구현할 수 있습니다. 

     

    star가 되고나서 Tistory

    반응형

    댓글