swan999 @ 2024-03-12 15:13:43
最后一个样例老是tle 哭
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static int a,b;
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static boolean is_Reverse(int num){
String str = num + "";
char[] c = str.toCharArray();
for(int i = str.length() - 1;i >= 0;i --)
if(str.charAt(i) != c[str.length() - 1 - i])
return false;
return true;
}
static boolean is_zs(int num){
if(num == 2)
return true;
for(int i = 2;i <= Math.sqrt(num);i ++)
if(num % i == 0)
return false;
return true;
}
public static void main(String[] args){
Scanner sc = new Scanner(new BufferedInputStream(System.in));
a = sc.nextInt();
b = sc.nextInt();
if(a == 1 || a == 2) {
out.println(2);
a = 3;
}
for(int i = a;i <= b;i ++){
if(is_Reverse(i) && is_zs(i)){
out.println(i);
}
}
out.flush();
out.close();
}
}
by Lian_zy @ 2024-03-12 20:52:27
@tzl_Dedicatus545 看来大佬脾气不太好啊qwq
验证码dpxf寄