일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 디스크 컨트롤러
- 프로그래머스
- heap
- 통계학
- 프로젝트오일러
- Turbulent
- Fluid Dynamics
- Compressible Flow
- 파이썬
- Blasius
- FTCS
- Crank-Nicolson
- Navier-Stokes
- regression
- 유체역학
- Boundary Layers
- 우선순위큐
- programmers
- Laminar
- 힙
- 예제
- projecteuler
- Python
- Heat Equation
- Fluids
- 회귀
- 이중우선순위큐
- Finite Difference Method
- python3
- Statistics
- Today
- Total
Sudal's Garage
Project Euler 30 본문
Question:
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44As 1 = 14 is not a sum it is not included.
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
문제:
놀랍게도 각 자릿수의 네제곱의 합이 자기자신과 같은 수는 오로지 세 수 뿐이다.
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 441 = 14 은 합이라고 볼 수 없으므로 포함되지 않는다.
이 수들의 합은 1634 + 8208 + 9474 = 19316 이다.
각 자릿수의 다섯제곱의 합이 자기자신과 같은 수를 모두 찾아 그 합을 구하여라.
Solution:
print(sum([i for i in range(10,200000) if i == eval(" ** 5 +".join(list(str(i) + str(0))))]))
숫자를 str 형식으로 만들어주고, 그 사이사이에 ** 5 를 붙여 5제곱을 표현해준다. str(0)이 뒤에 붙은 이유는, 이것이 없다면 마지막 자리수의 5제곱은 빠지게 된다. 0 의 5제곱은 합에 영향을 주지 않는다.
2.42 초 걸렸다!
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 32 (0) | 2019.03.25 |
---|---|
Project Euler 31 (0) | 2019.03.24 |
Project Euler 29 (0) | 2019.03.17 |
Project Euler 28 (0) | 2019.03.16 |
Project Euler 26 (0) | 2019.03.16 |