1008. Daffodils, 1008 daffodils
1008. Daffodils (Standard IO) Time Limit: 1000 MS space limit: 262144 KB Specific Limit
Enter a three-digit number n in the topic description to determine whether the number of daffodils is used. If YES, "YES" is output. If not, "NO" is output ". Daffodils: A three-digit number. The sum of the three powers of the numbers in each digit equals to itself. (For example, 1 ^ 3 + 5 ^ 3 + 3 ^ 3 = 153) Enter a three-digit n. Output the corresponding results according to the topic description. Sample Input
153
Sample output
YES
Data range limit: 100 <= n <= 999
1 # include <iostream> 2 # include <cmath> 3 using namespace std; 4 int tot = 0; 5 int main () 6 {7 int n; 8 cin> n; 9 int j = n; 10 while (n! = 0) 11 {12 int a = n % 10; 13 double p = (double) pow (a, 3); 14 tot = tot + p; 15 n = n/10; 16} 17 if (tot = j) 18 {19 cout <"YES"; 20} 21 else22 {23 cout <"NO "; 24} 25 return 0; 26}