java可以这样实现不超时 public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); long num = Long.parseLong(br.readLine()); long old_n=0; while(num !=1){ for (int i = 2; i<=Math.sqrt(num); i++) { old_n=num; while (num % i == 0) { System.out.print(i + " "); num /= i; } if(old_n !=num)break; } if(old_n ==num){ System.out.print(num + " "); break; } } } }
点赞

相关推荐

牛客网
牛客企业服务