1008. Daffodils, 1008 daffodils

Source: Internet
Author: User

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}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.