题目描述
//package 蓝桥2023czw; import java.util.Scanner; import java.util.ArrayList; public class Main{ public static void main(String[]args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int m=input.nextInt(); int count=0; ArrayList<Integer>list=new ArrayList<>(); int i=2; while(count<m) { if(cheak(i)) { count++; if(count>=n) { list.add(count); } } i++; } int k=0; for (int j = 0; j <list.size() ; j++) { k++; if(k%10!=1) System.out.print(" "); System.out.print(list.get(j)); if(k%10==0) System.out.println(""); } } public static boolean cheak(int k) { for(int i=2;i<Math.sqrt(k);i++) { if(k%i==0) { return false; } } return true; } }
标签:count,java,Scanner,int,PTA,nextInt,素数,input From: https://www.cnblogs.com/liliczw2209/p/17455606.html