洛谷P1217质数口袋 麻烦看一下我写的代码该如何优化才不能超时
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
boolean[] is_prime = new boolean[b + 1];
Arrays.fill(is_prime,true);
for(int i = 2;i <= Math.sqrt(b);i++){
if(is_prime[i]){
int index = 2;
for(int j = i;j * index < b;index++){
is_prime[j * index] = false;
}
}
}
for(int i = Math.max(a,2);i <= b;i++){
if(is_prime[i] && (i % 2 != 0) && is_Palindromic(i)){
System.out.println(i);
}
}
}
//用来判断回文数
public static boolean is_Palindromic(int n){
int reverse = 0;
int origin = n;
while(n > 0){
int digital = n % 10;
reverse = reverse * 10 + digital;
n /= 10;
}
return origin == reverse;
}
}