fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin >> t;
  9. while(t--)
  10. {
  11. int n;
  12. cin >> n;
  13. int i = 2;
  14. while(i <= n)
  15. {
  16. if(n%i == 0)
  17. {
  18. int d = 0;
  19. while(n%i == 0)
  20. {
  21. n /= i;
  22. d++;
  23. }
  24. cout << i << " (" << d << ") ";
  25. }
  26. i++;
  27. }
  28. cout << '\n';
  29. }
  30. }
Success #stdin #stdout 0.01s 5292KB
stdin
3
60 
128
127
stdout
2 (2) 3 (1) 5 (1) 
2 (7) 
127 (1)