[파이썬][백준 2742번] 기찍 N
1. 문제Permalink
[Bronze III] 기찍 N - 2742Permalink
성능 요약Permalink
메모리: 30864 KB, 시간: 120 ms
분류Permalink
구현(implementation)
문제 설명Permalink
자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.
입력Permalink
첫째 줄에 100,000보다 작거나 같은 자연수 N이 주어진다.
출력Permalink
첫째 줄부터 N번째 줄 까지 차례대로 출력한다.
출처: 백준, https://https://www.acmicpc.net/
2. 해결방법 시간복잡도Permalink
- 단순 코딩 O(N)
3. 문제 해결 및 코드Permalink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
N = int(sys.stdin.readline()) | |
for i in range(N, 0, -1): | |
print(i) |
-
주석을 참고하면서 이해를 돕습니다.Permalink
4. 알고리즘 및 해설Permalink
- 1부터 입력값까지 반복문을 뒤로 돌리면서 위치값을 출력해준다.