(2429)水仙花数
Time Limit:1000MS Memory Limit:65536K
Total Submit:4553 Accepted:2363
Description
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 = 1*1*1 + 5*5*5 + 3*3*3. 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 Hint
注意:计算某个数n的3次方,不要用pow(n,3),而应该为:n * n * n。原因pow的参数是double型,会有精度问题。 Source
Zhejiang Provincial Programming Contest 2006, Preliminary
答案:
#include int main() {int m,a,b,c;
while(scanf(\"%d\ {
scanf(\"m\ a=m%10;
b=(m/10)%10; c=m/100;
if(m==a*a*a+b*b*b+c*c*c) {
printf(\"Yes\\n\"); } else {
printf(\"No\\n\"); } } }