解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for (int i = a; i <= b; i++) { int z = f(i); if (z != 0) { for (int j = 1; j < (z + "").length(); j++) { String s = z + ""; int v1 = Integer.parseInt(s.substring(0, j)); int v2 = Integer.parseInt(s.substring(j)); if (Math.sqrt(v1) % 1 == 0 && Math.sqrt(v2) % 1 == 0 && v1 > 0 && v2 > 0) { System.out.println(z); } } } } } public static int f(int i) { int z = 0; for (int m = 1; m <= Math.sqrt(i); m++) { if (m * m == i) { z = i; break; } } return z; } }
0.0分
1 人评分
C二级辅导-同因查找 (C语言代码)浏览:626 |
简单的a+b (C语言代码)浏览:719 |
九宫重排 (C++代码)浏览:1410 |
【蟠桃记】 (C语言代码)浏览:710 |
A+B for Input-Output Practice (II) (C语言代码)浏览:1043 |
简单的a+b (C语言代码)浏览:641 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:580 |
字符逆序 (C语言代码)浏览:645 |
蚂蚁感冒 (C语言代码)浏览:816 |
C二级辅导-求偶数和 (C语言代码)浏览:707 |