Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- int n;
- cin >> n;
- map<int, int> mp;
- // perform prime factorization and store the frequency (exponent) of each prime divisor
- int factor = 2;
- while (n > 1) {
- if (n % factor == 0) {
- mp[factor]++;
- n /= factor;
- } else {
- factor++;
- }
- }
- // calculate the product of all frequencies (exponents) of the prime numbers
- // don't forget to add one (1) to every frequency since prime numbers can be divided by one (1)
- int ans = 1;
- for (auto& x : mp) {
- ans *= (x.second + 1);
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement