반응형
Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
05-19 00:03
관리 메뉴

ImJay

[파이썬/Python] 백준 26574번 Copier 본문

Solved.ac - Python/Bronze V

[파이썬/Python] 백준 26574번 Copier

ImJay 2023. 6. 5. 04:23
반응형

[파이썬/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개의 숫자를 입력받고, 각 숫자와 숫자의 복사본을 출력하기 때문에 입력 크기에 비례하여 실행 시간이 증가한다. 따라서 입력 크기에 따라 선형적으로 실행 시간이 증가한다.

반응형
Comments