原来还可以使用while直接不停除,把相同因数全部除掉
这样除不需要考虑因数是不是质数,因为如果不是质数,会直接被这个数的因数先除掉
循环结束以后要判断现在的temp是不是1,如果不是一,那就说明它是质数,那么count++
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner=new Scanner(System.in);
int t=scanner.nextInt();
while(t-->0) {
int x=scanner.nextInt();
int temp=x;
int count=0;
for (int i = 2; i <= Math.sqrt(x); i++) {
while(temp%i==0) {
temp=temp/i;
count++;
}
}
if(temp>1) {
count++;
}
if(count%2==0) {
System.out.println("yukari");
}else {
System.out.println("kou");
}
}
}
}



京公网安备 11010502036488号