[파이썬][백준 15894번] 수학은 체육과목 입니다
1. 문제Permalink
[Bronze V] 수학은 체육과목 입니다 - 15894Permalink
성능 요약Permalink
메모리: 30864 KB, 시간: 72 ms
분류Permalink
사칙연산(arithmetic), 수학(math)
출처: 백준, https://https://www.acmicpc.net/
2. 해결방법 시간복잡도Permalink
- 단순 코딩 O(1)
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()) | |
print(N * 4) |
-
주석을 참고하면서 이해를 돕습니다.Permalink
4. 알고리즘 및 해설Permalink
- 한 변의 길이를 기준으로 가장 아랫부분의 정사각형 개수가 나오게 된다.
- 가장 밑의 사각형이 1개인 경우 총 변의 길이는 1 * 4 이므로 4이다.
- 그러므로 정사각형의 개수 * 4를 해준 값을 출력해준다.