[파이썬][백준 23037번] 5의 수난
1. 문제Permalink
[Bronze III] 5의 수난 - 23037Permalink
성능 요약Permalink
메모리: 30840 KB, 시간: 72 ms
분류Permalink
사칙연산(arithmetic), 수학(math)
출처: 백준, 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 | |
input = sys.stdin.readline | |
N = str(int(input())) | |
cnt = 0 | |
for i in N: | |
cnt += int(i) ** 5 | |
print(cnt) |
-
주석을 참고하면서 이해를 돕습니다.Permalink
4. 알고리즘 및 해설Permalink
- 입력값을 정수형으로 받은 뒤 다시 문자열로 받는다.
- 해당 문자열의 각각의 문자의 수의 5제곱을 변수에 더해준뒤 변수를 출력한다.