题目链接:https://projecteuler.net/problem=30
(9^5)*10=590490
所以答案直接暴力就行了
代码:
#include<bits/stdc++.h>
using namespace std;
int pow5(int x)
{
return x*x*x*x*x;
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int ans=0;
for(int i=2;i<=1000000;i++)
{
int tot=0,x=i;
while(x)
{
tot+=pow5(x%10);
x/=10;
}
if(tot==i)
ans+=i;
}
printf("%d\n",ans);
return 0;
}