fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void executeTime() {
  5. cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " secs";
  6. }
  7.  
  8. int main() {
  9.  
  10. int n; cin >> n;
  11.  
  12. map<int, int> mp;
  13.  
  14. while (n % 2 == 0) {
  15. mp[2]++;
  16. n >>= 1;
  17. }
  18.  
  19. for (int i = 3; i <= sqrt(n); i += 2) {
  20. while (n % i == 0) {
  21. mp[i] ++;
  22. n /= i;
  23. }
  24. }
  25.  
  26. if (n > 1) {
  27. mp[n]++;
  28. }
  29.  
  30. for (auto &x : mp) {
  31. cout << x.first << ' ' << x.second << endl;
  32. }
  33.  
  34.  
  35.  
  36.  
  37. executeTime();
  38. return 0;
  39. }
Success #stdin #stdout #stderr 0s 5320KB
stdin
10
stdout
2 1
5 1
stderr
Time Taken: 0.004355 secs