package PTACZW; //随机函数 //输入一个n; //随机出项1~n的数 import java.util.Scanner; import java.util.Random; import java.util.Set; import java.util.HashSet; import java.util.ArrayList; public class Main{ public static void main(String[]args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); long []ant=new long[n]; for(int i=0;i<n;i++) { ant[i]=input.nextInt(); } ArrayList<Long> list=new ArrayList<>(); for(int i=0;i<n;i++) { list.add(fac(ant[i])); } for(int i=0;i<list.size();i++) { if(list.get(i)==1) { System.out.print("YES"+" "); } else { System.out.print("NO"+" "); } } } public static long fac(long x) { ArrayList<Long> list=new ArrayList<>(); for(long i=1;i<=Math.sqrt(x);i++) { if(x%i==0) { list.add(i); if(i!=x/i) { list.add(x/i); } } } for(Long i:list) { System.out.println(i+" "); } System.out.println(); if(list.size()==3) { return 1; } else { return 0; } } }
标签:java,int,初赛,util,long,2022,new,import,之星 From: https://www.cnblogs.com/liliczw2209/p/17539445.html