为什么最大只能输出5位数啊???

P1217 [USACO1.5] 回文质数 Prime Palindromes

chengxuyuan666 @ 2023-06-02 16:41:49


import java.util.*;
public class Main {
    public static void main(String[] args)
    {
        try (Scanner sc = new Scanner(System.in)) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            for(int i=a;i<=b;i++)
            {
                if(i>=5&&i<10)//1
                {
                    if(chek(i)==false)
                        System.out.println(i);
                }
                else if(i<100)//2
                {   if(i%10==i/10&&chek(i)==false)
                        System.out.println(i);
                }
                else if(i<1000)//3
                {
                    if(i%10==i/100&&chek(i)==false)
                        System.out.println(i);
                }
                else if(i<10000)//
                {
                    if(i%10==i/1000&&i%1000/100==i%100/10&&chek(i)==false)
                        System.out.println(i);
                }
                else if(i<100000)
                    if(i%10==i/10000&&i%100/10==i%10000/1000&&chek(i)==false)
                        System.out.println(i);
                else if(i<1000000)
                    if(i%10==i/100000&&i%100/10==i%100000/10000&&i%1000/100==i%10000/1000&&chek(i)==false)
                        System.out.println(i);
                else if(i<10000000)
                    if(i%10==i/1000000&&i%100/10==i%1000000/100000&&i%1000/100==i%100000/10000&&chek(i)==false)
                        System.out.println(i);
                else if(i<100000000)
                    if(i%10==i/10000000&&i%100/10==i%10000000/1000000&&i%1000/100==i%1000000/100000&&i%10000/1000==i%100000/10000&&chek(i)==false)
                        System.out.println(i);
            }
        }

    }

    public static boolean chek(int b)
    {
        boolean k=false;
        for(int i=2;i<=Math.sqrt(b);i++)
        {
            if(b%i==0)
                {k=true;
                return k;}
        }
        return k;
    }
}

by Tim_the_best @ 2023-06-03 14:57:54

jave我不会


|