注意下1就好
import java.util.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); while (in.hasNext()){ int n = in.nextInt(); int res = 0; for (int i = 0; i < n; i++){ int k = 1; while(k < i) k*= 10; int b = i * i / k; int c = i * i - b * k; if (c == i){ res++; } } System.out.println(res+1); } } }