Blue Bridge Cup algorithm training ALGO-126 daffodils

Source: Internet
Author: User
Tags pow

Algorithm training Narcissus time limit: 1.0s memory limit: 256.0MB Narcissus number problem description judge given three-digit numberWhether Narcissus number. The so-called Narcissus number refers to its value equal to its own number of cubic meters per digit. Example 153 is a number of daffodils. 153=13+53+33 an integer in the input format. Output format is narcissus number, output "YES", otherwise output "no" (not including quotation marks) sample input 123 sample output no data size and convention a three-bit integer, otherwise output "No" Sample code:
1 ImportJava.util.Scanner;2 3  Public classMain {4      Public Static voidMain (string[] args) {5Scanner sc =NewScanner (system.in);6         intn =sc.nextint ();7         if(<= n | | n <= 999) {//Is the three-digit number8             intA = n/100;//Hundred9             intb = n% 100/10;//10 GuestsTen             intc = n% 10;//Digit One             if(n = = Math.pow (a,3) +math.pow (b, 3) +math.pow (c, 3)) {//determine if the number of daffodils is ASystem.out.println ("YES"); -}Else{ -System.out.println ("NO"); the             } -}Else{ -System.out.println ("NO"); -         } +     } -}

Blue Bridge Cup algorithm training ALGO-126 daffodils

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.