水仙花数是指一个 n 位数 ( n >= 3 ),它的每个位上的数字的 n 次幂之和等于它本身。(例如:1^3 + 5^3 + 3^3 = 153)
给出一个整数M,求 >= M的最小的水仙花数。
Input
一个整数M(10 <= M <= 1000)
Output
输出>= M的最小的水仙花数
Input示例
99
Output示例
153
本题可以通过枚举求水仙花数,为了简洁直接打表了
#include<iostream>
using namespace std;
int main()
{
int m;
cin>>m;
int a[10]={153,370,371,407,1634,8208,9474,54748,92727,93084};
for(int i=0;i<10;i++)
{
if(a[i]>=m)
{
cout<<a[i]<<endl;
break;
}
}
}