Daffodil number

Time Limit: 1 Second      Memory Limit: 32768 KB

The daffodil number is one of the famous interesting numbers in the mathematical world. A daffodil number is a three-digit number whose value is equal to the sum of cubes of each digit.

For example. 153 is a daffodil as 153 = 13 + 53 + 33.

Input

There are several test cases in the input, each case contains a three-digit number.

Output

One line for each case. if the given number is a daffodil number, then output "Yes", otherwise "No".

Sample Input

153
610

Sample Output

Yes
No

ZOJ <wbr>2736 <wbr>Daffodil <wbr>number
#include <iostream>
using namespace std;

bool judge(int num){
int a, b, c, fb=num;
a
=fb% 10; fb/=10;
b
=fb% 10; fb/=10;
c
=fb;
if(a*a*a+b*b*b+c*c*c== num)
return true;
else return false;
}
int main()
{
int num;
while(cin>>num){
if(judge(num))
cout
<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
posted on 2011-05-11 10:33  敌敌  阅读(329)  评论(0编辑  收藏  举报