[파이썬][백준 2440번] 별 찍기 - 3
1. 문제Permalink
[Bronze III] 별 찍기 - 3 - 2440Permalink
성능 요약Permalink
메모리: 30840 KB, 시간: 68 ms
분류Permalink
구현(implementation)
문제 설명Permalink
첫째 줄에는 별 N개, 둘째 줄에는 별 N-1개, ..., N번째 줄에는 별 1개를 찍는 문제
입력Permalink
첫째 줄에 N(1 ≤ N ≤ 100)이 주어진다.
출력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
n = int(input()) | |
for i in range(n, 0, -1): | |
print(i * "*") |
-
주석을 참고하면서 이해를 돕습니다.Permalink
4. 알고리즘 및 해설Permalink
- 반복문을 뒤에서 부터 돌아가게끔 만든다.
- 이는 점점 줄어드는 별을 만들기위해서이다.
- N번째부터 줄어드는 별을 출력한다.