Advertisement
Niloy007

C_Divisors_of_the_Divisors_of_An_Integer

May 15th, 2021
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define Niloy
  3. #define int int64_t
  4. #define mx (int) 1e7 + 123
  5. #define MOD (int) 1e7 + 7
  6. #define pb push_back
  7. #define pairs pair<int, int>
  8. #define vi vector<int>
  9. #define vb vector<bool>
  10. #define vii vector<pairs>
  11. #define lb lower_bound
  12. #define ub upper_bound
  13. #define endl '\n'
  14. #define llu unsigned long long
  15. using namespace std;
  16. /* ----------------------------------------------------------------------------------- */
  17.  
  18. // Input/Output
  19. #define fastInput ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  20. #define all(x) x.begin(), x.end()
  21. #define square(a) (a * a)
  22. #define mem(a, b) memset(a, b, sizeof(a))
  23.  
  24. // Fractional Number
  25. #define fraction()        cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
  26.  
  27. // Direction Array
  28. int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
  29. int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
  30.  
  31. // File I/O
  32. #define read(x)  freopen(x, "r", stdin);
  33. #define write(x) freopen(x, "w", stdout);
  34.  
  35. // Loops
  36. #define rep(i, a, n) for (int i = a; i < n; i++)
  37. #define REP(i, a, n) for (int i = a; i <= n; i++)
  38. #define rev(i, n, a) for (int i = n - 1; i >= a; i--)
  39. #define REV(i, n, a) for (int i = n; i >= a; i--)
  40.  
  41. /* ----------------------------------------------------------------------------------- */
  42.  
  43. #define Cases  cout << "Case " << ++Case << ": ";
  44. #define __test int tt; int Case=0; cin >> tt; while(tt--)
  45. #define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
  46.  
  47. #define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, m){cout<<A[i][j]<<"";}cout<<"\n";}cout<<"\n";}
  48. #define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
  49. #define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}
  50.  
  51. /* ----------------------------------------------------------------------------------- */
  52.  
  53. int gcd(int n, int m) { return m ? gcd(m, n % m) : n; }
  54. int lcm(int n, int m) { return n / gcd(n, m) * m; }
  55.  
  56. struct debugger {
  57.     typedef string::iterator si;
  58.     static void call(si it, si ed) {}
  59.     template<typename T, typename ... aT>
  60.     static void call(si it, si ed, T a, aT... rest) {
  61.         string b;
  62.         for(; *it!=','; ++it)
  63.             if(*it!=' ')
  64.                 b+=*it;
  65.         cout << b << "=" << a << " ";
  66.         call(++it, ed, rest...);
  67.     }
  68. };
  69.  
  70. /* ----------------------------------------------------------------------------------- */
  71. void input() {
  72. #ifdef Niloy
  73.     read("input.txt");  
  74.     write("output.txt");
  75. #endif
  76. }
  77.  
  78. /* ----------------------------------------------------------------------------------- */
  79.  
  80. bitset<mx> isPrime;
  81. vi Prime;
  82.  
  83. void primeGen(int n) {
  84.     for (int i = 3; i <= n; i += 2) {
  85.         isPrime[i] = 1;
  86.     }
  87.     isPrime[2] = 1;
  88.     int sq = sqrt(n);
  89.  
  90.     for (int i = 3; i <= sq; i += 2) {
  91.         if (isPrime[i]) {
  92.             for (int j = i * i; j <= n; j += (i * 2)) {
  93.                 isPrime[j] = 0;
  94.             }
  95.         }
  96.     }
  97.  
  98.     Prime.pb(2);
  99.     for (int i = 3; i <= n; i += 2) {
  100.         if (isPrime[i]) {
  101.             Prime.pb(i);
  102.         }
  103.     }
  104. }
  105.  
  106. void solve() {
  107.     int n;
  108.     int lim = 1e6;
  109.     primeGen(lim);
  110.  
  111.     while (cin >> n && n) {
  112.         int ans = 1;
  113.         for (auto p : Prime) {
  114.             if (p > n) {
  115.                 break;
  116.             }
  117.             int cnt = 1;
  118.             int tmp = n;
  119.             while (tmp > 0) {
  120.                 cnt += (tmp / p);
  121.                 tmp /= p;
  122.             }
  123.             int sum = ((cnt * (cnt + 1)) / 2);
  124.             sum %= MOD;
  125.             ans *= sum;
  126.             ans %= MOD;
  127.         }
  128.         cout << ans << endl;
  129.     }
  130. }
  131.  
  132. int32_t main() {
  133.     // input();
  134.     fastInput;
  135.     solve();
  136.  
  137.     // __test {
  138.     //  solve();
  139.     // }
  140.  
  141.     // showTime;
  142.     return 0;
  143. }
  144.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement