码迷,mamicode.com
首页 > 其他好文 > 详细

zoj 2736 Daffodil number

时间:2017-03-09 20:13:01      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:pre   ace   cube   zoj   font   mit   math   cin   ble   

Daffodil number

Time Limit: 2 Seconds      Memory Limit: 65536 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

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 int main(){
 5     int n, a, b, c;
 6     while(cin >> n){
 7         a = n / 100;
 8         b = n % 100 / 10;
 9         c = n % 10;
10         if(n == a * a * a + b * b *b + c * c * c)
11             cout << "Yes" << endl;
12         else
13             cout << "No" << endl;
14     }
15     return 0;
16 }

 

zoj 2736 Daffodil number

标签:pre   ace   cube   zoj   font   mit   math   cin   ble   

原文地址:http://www.cnblogs.com/qinduanyinghua/p/6527007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!