三位数的水仙花数
重点是,while 处不可恒成立,acm超时
于是用cin
#include <iostream>
using namespace std;
int main()
{
int a;
while (cin>>a)
{
int b, c, d;
if (a < 100 || a>999)
{
cout << "NO\n";
continue;
}
b = a % 10;
c = a / 10 % 10;
d = a / 100 % 10;
if (b * b * b + c * c * c + d * d * d == a)
cout << "YES"<<endl;
else cout << "NO"<<endl;
}
}