[백준/파이썬] 17010번 풀이

업데이트:



문제 정보


풀이

문제

You and your friend have come up with a way to send messages back and forth.

Your friend can encode a message to you by writing down a positive integer N and a symbol. You can decode that message by writing out that symbol N times in a row on one line.

Given a message that your friend has encoded, decode it.

입력 요약
The first line of input contains L, the number of lines in the message.

The next L lines each contain one positive integer less than 80, followed by one space, followed by a (non-space) character.

출력 요약
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.

코드

import sys;read=sys.stdin.readline
for T in range(int(read())):
    a,b=read().split()
    print(b*int(a))

설명

핵심은 구현 관점에서 You and your friend have come up with a way to send messages back and forth. …를 만족하도록 로직을 구성하는 것입니다.

코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.

경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.



댓글남기기