杭电ACM Java 2010水题wrong answer 跪求哪儿错了?
importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){Scannersc=...
import java.util.Scanner;
public class Main {
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
boolean q=false;
while(sc.hasNext()){
int m=sc.nextInt();
int n=sc.nextInt();
int a,b,c,x;
int f=0;
for(x=m;x<=n&x>=m;x++){
a=x/100;
b=(x-100*a)/10;
c=x-100*a-10*b;
f=a*a*a+b*b*b+c*c*c;
if(x==f){
System.out.print(x+" ");
q=true;
}
}if(!q){
System.out.println("no");
}
}
}
} 展开
public class Main {
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
boolean q=false;
while(sc.hasNext()){
int m=sc.nextInt();
int n=sc.nextInt();
int a,b,c,x;
int f=0;
for(x=m;x<=n&x>=m;x++){
a=x/100;
b=(x-100*a)/10;
c=x-100*a-10*b;
f=a*a*a+b*b*b+c*c*c;
if(x==f){
System.out.print(x+" ");
q=true;
}
}if(!q){
System.out.println("no");
}
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询