zoj 2736 Daffodil number

Posted 琴影

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zoj 2736 Daffodil number相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

zoj Beautiful Number(打表)

zoj 2001 Adding Reversed Numbers

ZOJ 3622 Magic Number(数)

ZOJ3180 Number Game

zoj3886--Nico Number(素数筛+线段树)

ZOJ 1078 Palindrom Numbers