题解 | #水仙花数#
水仙花数
https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); while (scan.hasNextInt()) { int m = scan.nextInt(); int n = scan.nextInt(); int x = 0; for (int i = m; i <= n; i++) { int a = i / 100; int b = i / 10 % 10; int c = i % 10; if (a * a * a + b * b * b + c * c * c == i) { System.out.print(i + " "); x = 1; } else { if (i == n && x == 0) { System.out.println("no"); } } } } } }