acm2010

/**

* 水仙花数

*/

import java.util.*;

public class acm2010{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

while(in.hasNextInt()){

int firstNum = in.nextInt();

int lastNum
= in.nextInt();

String result= "";

for(int i = firstNum ; i <= lastNum ; i++){

int t1,t2,t3;

t3=i/100;

t2=(i-t3*100)/10;

t1=(i-t3*100 - t2*10);

// t3=i/100;

// t2=i%100/10;

// t1=i%10;

if( i==(t3*t3*t3 + t2*t2*t2 + t1*t1*t1 ) ){

result=result + Integer.toString(i) + " ";

}

}

if(result == ""){

System.out.println("no");

}else{

System.out.println(result.substring(0,result.length() - 1));

}

}

}

}

时间: 2024-12-20 18:03:07

acm2010的相关文章