题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); int count = 0; for(int i = 0; i <= num; ++i){ String pow = String.valueOf((int) Math.pow(i, 2)); if(pow.endsWith(String.valueOf(i))){ count++; } } System.out.println(count); } }