fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n; cin >> n;
  6. for(int i=2; i *i <= n; i++){
  7. int c = 0;
  8. while(n % i ==0){
  9. n/=i;
  10. c++;
  11. }
  12. if(c){
  13. cout << i << " " << c << "\n";
  14. }
  15. }
  16. if(n > 1){
  17. cout << n << " " << 1;
  18. }
  19. }
Success #stdin #stdout 0s 5284KB
stdin
24
stdout
2 3
3 1