project euler problem 30
2013-10-20 14:08
369 查看
Digit fifth powers
Problem 30
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 + 44
As 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.
|
暴力解决……
#include <iostream> #include <map> #include <deque> #include <queue> #include <stack> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <map> #include <set> using namespace std; int main() { int i,j,n,sum,sum1=0; for(n=2;n<=10000000;n++) { j=n; sum=0; while(j) { int t=j%10; sum+=t*t*t*t*t; j/=10; } if(sum==n) sum1+=sum; } cout<<sum1<<endl; return 0; }
相关文章推荐
- Project Euler Problem 30
- http://projecteuler.net/problem=30 [Answer:443839]
- Project Euler Problem 30
- Project Euler problem 30
- Project euler problem 21 - 30
- Project Euler problem 21
- Project Euler problem 43
- Project Euler problem 53
- Project Euler Problem 3
- projecteuler Problem 29
- http://projecteuler.net/problem=19 [Answer:171]
- Project Euler Problem 1: Multiples of 3 and 5
- project euler Problem 15
- Project Euler Problem 11: Largest product in a grid
- Project Euler Problem 47 Distinct primes factors
- Project Euler Problem 32 Pandigital products
- Project Euler -> problem 4
- project euler problem 10:Summation of primes
- Project Euler Problem 40
- Project Euler Problem 10