fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int snt(int x){
  4. if(x<=2) return 1;
  5. for(int i=2;i*i<=x;i++) if(x%i==0) return 0;
  6. return 1;
  7. }
  8. int main(){
  9. int t;
  10. cin>>t;
  11. int dem=0;
  12. while(t--){
  13. dem++;
  14. int n;
  15. cin>>n;
  16. cout<<"Test "<<dem<<" ";
  17. int a[10001]={};
  18. int c=0;
  19. int b[10001]={};
  20. int d=0;
  21. int j=2;
  22. while(n>=j){
  23. if(n%j==0&&snt(j)){
  24. b[j]++;
  25. if(b[j]==1){
  26. a[c]=j;
  27. c++;
  28. }
  29. n/=j;
  30. }
  31. else {
  32. j++;
  33. }
  34. }
  35. for(int i=0;i<c;i++) cout<<a[i]<<" "<<"("<<b[a[i]]<<")"<<" ";
  36. cout<<endl;
  37. }
  38. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty