题解 | #水仙花数#
水仙花数
http://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { int flag=0; int m=sc.nextInt(); int n=sc.nextInt(); for(int i=m;i<=n;i++) { int one=i/100; int two=i%100/10; int three=i%10; if(i==(Math.pow(one,3)+Math.pow(two,3)+Math.pow(three,3))) { System.out.print(i+" "); flag=1; } } if(flag==0) { System.out.println("no"); } } } }