Blue Bridge Cup algorithm training ALGO-147 4-3 daffodils number

Source: Internet
Author: User
Tags pow

Algorithm training 4-3 Daffodils number time limit: 1.0s memory Limit: 256.0MB problem description Print all daffodils between 100 and 999. The so-called Narcissus number refers to the number of cubes that satisfy them and the integers for the number itself, such as 153=1^3+5^3+3^3. Sample input An input example that satisfies the requirements of the topic.
Cases:
No sample output 153
Xxx
Xxx Topic Analysis: This is a simple problem of brute force cracking. Simply break down the hundred, 10, and digits of each three-digit number, and then calculate whether the cubic is equal to the number. Example code:
1  Public classMain {2      Public Static voidMain (string[] args) {3          for(inti = 153; i < 1000; i++){4             intA = i/100;//Hundred5             intb = i% 100/10;//10 Guests6             intc = i% 10;//Digit7             if(i = = (Math.pow (a,3) +math.pow (b,3) +math.pow (c,3))){8 System.out.println (i);9             }Ten         } One     } A}

Blue Bridge Cup algorithm training ALGO-147 4-3 daffodils number

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.