#9986: 幫忙看哪裡錯,測試是AC 上傳WA


akak32678 (unknown)


import java.util.*;

public class A040 {
// 阿姆斯壯數 荷花
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
int m = sc.nextInt();
if (m > n) {
if (m < 1001 && n > 99) {
for (int i = 100; i < 1000; i++) {
int a = i / 100;
int b = (i % 100) / 10;
int c = i % 10;
if (a * a * a + b * b * b + c * c * c == i)
System.out.print(i + " ");
}
System.out.println( );
}
if (m < 10001 && n > 999) {
for (int i = 1000; i < 10000; i++) {
int e = i % 10;
int f = i / 10 % 10;
int g = i / 100 % 10;
int h = i / 1000;
if (i == e * e * e * e + f * f * f * f + g * g * g * g
+ h * h * h * h)
System.out.print(i + " ");
}
System.out.println( );
}
if (m < 100 && n > 0)
System.out.println("none");
}
}
}
}

#13610: Re:幫忙看哪裡錯,測試是AC 上傳WA


snakeneedy (蛇~Snake)


注意題目範圍:n, m(n<m, n>0, m<=1,000,000)

也就是 1 ~ 1,000,000 之間的數,都有可能要考慮,而在你的 code 只考慮了 1 ~ 10,000