public class Main {
public static void main(String[] args) {
for (int i = 100; i < 1000; i++) {
String string = i+"";
int baiwei = i/100;
int shiwei = Integer.parseInt((string.charAt(1)+""));
int gewei = Integer.parseInt((string.charAt(2)+""));
//Math.pow(x,3)就是立方。 Math.pow(底数,几次方)
int sum = (int) (Math.pow(baiwei, 3)+Math.pow(shiwei, 3)+Math.pow(gewei,3));;
if (sum == i) {
System.out.println(i);
}
}
}
}
蓝桥杯-特殊的数字
最新推荐文章于 2024-02-26 22:11:49 发布