题解 | #自守数#
自守数
http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
简单粗暴,还以为要整大数呢
import java.util.Scanner;
public class Main {
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) + "").endsWith(i+"")) {
selfHoldNumber++;
}
}
System.out.println(selfHoldNumber);
}
}
}