在[0,n]的区间挨个来尝试,用正则匹配来判断是否符合条件,简单的一匹

import java.util.Scanner;
public class Test99 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int selfHoldNumber = 0;
            for (int i = 0; i <= n; i++) {
                if (((int) Math.pow(i, 2) + "").matches("[0-9]*" + i + "$")) {
                    selfHoldNumber++;
                }
            }
            System.out.println(selfHoldNumber);
        }
    }
}