PS 부수기
Project Euler #30 : Digit fifth powers 본문
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
int solve(int n) {
int ret = 0;
while (n > 0) {
int t = n % 10;
ret += t*t*t*t*t;
n /= 10;
}
return ret;
}
int main() {
int sum = 0;
for (int i = 2; i <= 1000000; i++) {
if (solve(i) == i) {
debug(i);
sum += i;
}
}
cout << sum;
}
|
cs |
문제 제작자는 왜 굳이 1을 제외한걸까..?
아 그리고 백만 위로 없다는 것은 999999의 case를 보면 쉽게 증명 가능!
+ 궁금해서 뭔 놈이 그런지 본 결과
4150
4151
54748
92727
93084
194979
요놈들이랍니다..
'Project Euler' 카테고리의 다른 글
Project Euler #32 : Pandigital products (0) | 2020.08.08 |
---|---|
Project Euler #31 : Coin sums (0) | 2020.08.08 |
Project Euler #29 : Distinct powers (0) | 2020.08.08 |
Project Euler #28 : Number spiral diagonals (0) | 2020.08.08 |
Project Euler #27 : Quadratic primes (0) | 2020.08.08 |
Comments