import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int i = 0;
for(i = (int)Math.pow(10, n-1); i <= (int)Math.pow(10, n)-1; i++) {
if(isFlower(i, n) > 0) {
System.out.println(i);
}
}
input.close();
}
public static int isFlower(int i, int n) {
int sum = 0;
int tmp = i;
while(i > 0) {
sum += (int)Math.pow(i%10, n);
i /= 10;
}
if(sum == tmp) {
return 1;
}else {
return -1;
}
}
}
要输出水仙花数,运行结果都对,但是他提示我超时啊,有没啥好的解决办法,感谢