题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
import java.io.IOException;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
long zhi = sc.nextInt();
long k1 =zhi;
long j = 1;
long k2 = (long) Math.sqrt(zhi);
for(long i = 2; i < k2;i++){
long result = zhi%zhi;
long result1 = zhi/zhi;
while(result == 0){
result = zhi%i;
if(result == 0) {
result1 = zhi/i;
zhi = result1;
System.out.print(i);
System.out.print(" ");
j=j*i;
}
}
}
if(k1 == k2*k2){
System.out.print(k2 +" " + k2);
return;
}
if(k1 > j){
System.out.println(k1/j);
}
}
}
}
#华为OD机考#
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
long zhi = sc.nextInt();
long k1 =zhi;
long j = 1;
long k2 = (long) Math.sqrt(zhi);
for(long i = 2; i < k2;i++){
long result = zhi%zhi;
long result1 = zhi/zhi;
while(result == 0){
result = zhi%i;
if(result == 0) {
result1 = zhi/i;
zhi = result1;
System.out.print(i);
System.out.print(" ");
j=j*i;
}
}
}
if(k1 == k2*k2){
System.out.print(k2 +" " + k2);
return;
}
if(k1 > j){
System.out.println(k1/j);
}
}
}
}
#华为OD机考#

