import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
        for(int i = 1000; i <= n; i++){
           int sum = 0;
            int d = i % 10;
            int c = i / 10 % 10;
            int b = i / 100 % 10;
            int a = i / 1000;
            sum = ((a * 10 + b) + (c * 10 + d)) * ((a * 10 + b) + (c * 10 + d));
            if(sum == i){
                System.out.println(i);
            }
           }
        
    } 
}
因为只有四位数,可将个个位上的数字拿出来,然后进行操作,在于原来的数进行比较。