Beingamanforever

Hackerrank Q

Nov 10th, 2024
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. /**
  2.  *    author:  compounding
  3.  *    created: 2024-11-10 18:29:38
  4.  **/
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7. mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
  8. #define NeedForSpeed                  \
  9.     ios_base::sync_with_stdio(false); \
  10.     cin.tie(NULL);                    \
  11.     cout.tie(NULL);
  12. #define int long long
  13. #define all(x) (x).begin(), (x).end()
  14. typedef vector<int> vi;
  15. typedef vector<pair<int, int>> vpi;
  16. #define f first
  17. #define s second
  18. #define endl "\n"
  19. const int mod = 1000007;
  20.  
  21. void solve()
  22. {
  23.     int N;
  24.     cin >> N;
  25.     map<int, int> prime_exponents;
  26.     for (int i = 2; i <= N; i++)
  27.     {
  28.         int num = i;
  29.         for (int p = 2; p * p <= num; p++)
  30.         {
  31.             while (num % p == 0)
  32.             {
  33.                 prime_exponents[p]++;
  34.                 num /= p;
  35.             }
  36.         }
  37.         if (num > 1)
  38.         {
  39.             prime_exponents[num]++;
  40.         }
  41.     }
  42.     int result = 1;
  43.     for (auto &pe : prime_exponents)
  44.     {
  45.         int exponent = pe.second * 2;
  46.         result = (result * (exponent + 1)) % mod;
  47.     }
  48.     cout << result << endl;
  49. }
  50.  
  51. signed main()
  52. {
  53.     NeedForSpeed;
  54.     solve();
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment