fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. void solve(int t){
  6. cout << "Test " << t << ": ";
  7. int n; cin >> n;
  8. for(int i=2; i*i <= n; i++){
  9. int c = 0;
  10. while(n % i == 0){
  11. n /= i;
  12. c++;
  13. }
  14. if(c > 0){
  15. cout << i << "(" << c << ")" << " ";
  16. }
  17. }
  18. if(n > 1){
  19. cout << n << "(1)";
  20. }cout << "\n";
  21. }
  22.  
  23. int main(){
  24. int typetest = 1;
  25. int test;
  26. if(typetest){
  27. cin >> test;
  28. for(int i=1; i <= test; i++){
  29. solve(i);
  30. }
  31. }else solve(1);
  32. }
Success #stdin #stdout 0.01s 5284KB
stdin
3
60
128
10000
stdout
Test 1: 2(2) 3(1) 5(1)
Test 2: 2(7) 
Test 3: 2(4) 5(4)