-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhanTichThuaSoNguyenTo.java
More file actions
45 lines (44 loc) · 1.27 KB
/
PhanTichThuaSoNguyenTo.java
File metadata and controls
45 lines (44 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package baitap;
import java.util.*;
/**
*
* @author khanh
*/
public class PhanTichThuaSoNguyenTo {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long t=sc.nextLong();
for(int z=1;z<=t;z++){
long n=sc.nextLong();
System.out.print("Test "+z+": ");
if(n==1){
System.out.println(1+"("+1+")");
}
else{
for (int i=2;i<=Math.sqrt(n);i++){
int cnt=0;
while(n%i==0){
cnt++;
n/=i;
}
if(cnt>0){
System.out.print(i+"("+cnt+")");
}
if(n>1&& cnt>0){
System.out.print(" ");
}
}
if(n>1){
System.out.println(n+"("+1+")");
}
else{
System.out.println();
}
}
}
}
}