fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int process(int n)
  5. {
  6. int ex=1;
  7. long long ans=1;
  8.  
  9. while(!(n%2)){
  10. n/=2;
  11. ex++;
  12. }
  13.  
  14. ans=ans*(ex);
  15. for(int i=3;i*i<=n;i+=2){//we will go till root(n) only as after that only one prime would be left or 1
  16.  
  17. ex=1;
  18. while(!(n%i)){
  19. n/=i;
  20. ex++;
  21. //push I if you want all the primes
  22. }
  23. ans*=(ex);
  24.  
  25. }
  26. if(n>1) ans*=2;
  27. //push n if you want all the prime factors
  28. return ans;
  29. }
  30. int main()
  31. {
  32. int n;cin>>n;
  33. cout<<process(n);
  34. }
  35.  
Success #stdin #stdout 0s 4184KB
stdin
100
stdout
9