您好,欢迎来到微智科技网。
搜索
您的当前位置:首页水仙花数

水仙花数

来源:微智科技网
(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\"); } } }

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务