题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static java.util.Arrays.*;
import static java.util.stream.Stream.*;
public class Main {
public static void main(String[] args) throws IOException {
testTh();
}
private static void testTh() throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str;
while ((str = bf.readLine()) != null) {
int parseInt = Integer.parseInt(str);
int count = 0;
for (int i = 0; i <= parseInt; i++) {
Integer pow = (int) (Math.pow(i, 2));
String s1 = i + "";
String s = pow + "";
if (s1.equals(s.substring(s.length() - s1.length()))) {
count++;
}
}
System.out.println(count);
}
}
}