fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef pair<int, int> PII;
  5.  
  6. const int MAX_N = 1e4+5;
  7. const int inf = 1e9;
  8.  
  9. int rozklad(int x) {
  10. int wynik = 0;
  11. int i = 2;
  12.  
  13. while (i*i <= x) {
  14. if (x == 1) break;
  15.  
  16. if (x % i == 0) {
  17. wynik++;
  18. while (x % i == 0) {
  19. x /= i;
  20. }
  21. }
  22.  
  23. i++;
  24. }
  25.  
  26. if (x > 1) {
  27. wynik++;
  28. }
  29.  
  30. return wynik;
  31. }
  32.  
  33. int main() {
  34. ios_base::sync_with_stdio(0);
  35. cin.tie(0);
  36.  
  37. cout << rozklad(17) << '\n';
  38. cout << rozklad(120) << '\n';
  39. cout << rozklad(354) << '\n';
  40.  
  41.  
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
1
3
3