[파이썬/Python] 백준 26574번 Copier
[파이썬/Python] 백준 26574번 Copier
26574번: Copier
Your copier broke down last week, and you need to copy a list of numbers for a class project due tomorrow! Luckily, you can use your computer to copy the numbers for you. Given a list of numbers, each on their own line, print out the number, a space, and t
www.acmicpc.net
문제
Your copier broke down last week, and you need to copy a list of numbers for a class project due tomorrow! Luckily, you can use your computer to copy the numbers for you. Given a list of numbers, each on their own line, print out the number, a space, and then another copy of the number.
지난 주에 복사기가 고장나서 내일 제출해야 할 수업 프로젝트의 숫자 목록을 복사해야 합니다! 다행히 컴퓨터를 사용하여 숫자를 복사할 수 있습니다. 숫자 목록이 주어지면 각 숫자를 원래 숫자와 공백, 그리고 숫자의 복사본으로 출력하세요.
입력
The first line will contain a single integer n that indicates the number of numbers to follow, each on their own line. The next n lines will each contain a single number.
첫 번째 줄에는 숫자의 개수를 나타내는 단일 정수 n이 주어집니다. 이어지는 n개의 줄 각각에는 하나의 숫자가 포함됩니다.
출력
For each of the n lines, print out the original number and a copy of the number, with one space of separation.
각 줄에 대해 원래 숫자와 숫자의 복사본, 그리고 공백 하나를 출력합니다.
예제 입력
3
7
3
10
예제 출력
7 7
3 3
10 10
풀이
# 숫자의 개수를 입력
n = int(input())
# n번 반복하여 숫자와 숫자의 복사본을 출력
for _ in range(n):
# 숫자를 입력
num = input()
# 숫자와 숫자의 복사본을 출력
print(num, num)
이 프로그램의 시간 복잡도는 O(n)이다. n개의 숫자를 입력받고, 각 숫자와 숫자의 복사본을 출력하기 때문에 입력 크기에 비례하여 실행 시간이 증가한다. 따라서 입력 크기에 따라 선형적으로 실행 시간이 증가한다.
