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