fork download
  1.  
  2. #include <bits/stdc++.h>
  3. #include <chrono>
  4. using namespace std;
  5. using namespace chrono;
  6. // "AJEET JAIN"----"JAI JINENDRA"
  7. /* "णमो अरिहंताणं",
  8.   "णमो सिद्धाणं",
  9.   "णमो आयरियाणं",
  10.   "णमो उवज्झायाणं",
  11.   "णमो लोए सव्वसाहूणं",
  12.   "",
  13.   "एसो पंच नमोक्कारो, सव्व पावप्पणासणो",
  14.   "मंगलाणं च सव्वेसिं, पडमं हवै मंगलं", */
  15.  
  16.  
  17. // Aliases to op
  18. using ll = long long;
  19. using ull = unsigned long long;
  20. using ld = double;
  21. using vll = vector<ll>;
  22.  
  23.  
  24. // Constants
  25. constexpr ll INF = 4e18;
  26. constexpr ld EPS = 1e-9;
  27. constexpr ll MOD = 1e9 + 7;
  28.  
  29.  
  30.  
  31. // Macros
  32. #define F first
  33. #define S second
  34. #define all(x) begin(x), end(x)
  35. #define allr(x) rbegin(x), rend(x)
  36. #define py cout<<"YES\n";
  37. #define pn cout<<"NO\n";
  38. #define forn(i,n) for(int i=0;i<n;i++)
  39. #define for1(i,n) for(int i=1;i<=n;i++)
  40.  
  41. // #define insert push_back
  42. #define pb push_back
  43. #define MP make_pair
  44. #define endl '\n'
  45.  
  46. /*
  47.   remove substring or subarray ---> try to think about sliding w
  48.  
  49.   */
  50.  
  51. /*
  52.  
  53.   Golden Rule
  54.  
  55.   1) problem is easy
  56.   2) proofs is easy
  57.   3) implementation is easy
  58.  
  59.   /*
  60.   ROUGH --
  61.  
  62.   */
  63. ll MAXN = 1e6;
  64. vector<ll> spf(MAXN + 1 );
  65.  
  66. void smallest_prime_factor() {
  67. spf[0] = spf[1] = 1;
  68.  
  69. for (int i = 2; i <= MAXN; i++) {
  70. if (spf[i] == 0) { // i is prime
  71. spf[i] = i;
  72. for (long long j = 1LL * i * i; j <= MAXN; j += i) {
  73. if (spf[j] == 0)
  74. spf[j] = i;
  75. }
  76. }
  77. }
  78. }
  79.  
  80. unordered_map<ll , ll> cl(ll vl){
  81. unordered_map<ll , ll> a2;
  82.  
  83. while(vl != 1){
  84. ll d = spf[vl];
  85. a2[d]++;
  86. vl = vl/d;
  87. }
  88. return a2;
  89. }
  90.  
  91.  
  92.  
  93. void AJNJ(){
  94. ll n,m;
  95. cin>>n>>m;
  96. smallest_prime_factor();
  97. unordered_map<ll , ll> b1;
  98. for(int i = 2 ; i <= m ; i++){
  99. unordered_map<ll , ll> a2 = cl(i);
  100.  
  101. for(auto itr = a2.begin() ; itr != a2.end() ; itr++){
  102.  
  103. b1[itr->first] += itr->second;
  104. }
  105.  
  106. }
  107.  
  108. ll b[n + 1];
  109.  
  110. for(int i = 1 ; i <= n ; i++){
  111. unordered_map<ll, ll> b5 = b1;
  112. ll ans = 1;
  113. cin >> b[i];
  114. unordered_map<ll , ll> a2 = cl(b[i]);
  115.  
  116. for(auto itr = a2.begin() ; itr != a2.end() ; itr++){
  117. b5[itr->F] += itr->S;
  118. }
  119.  
  120. for(auto x : b5){
  121. ans = (ans % MOD * ((x.second % MOD + 1 % MOD)% MOD)) % MOD;
  122. }
  123.  
  124. cout << ans << " ";
  125.  
  126. }
  127. cout << endl;
  128.  
  129.  
  130. }
  131.  
  132.  
  133. int main(){
  134. ios::sync_with_stdio(0);
  135. cin.tie(0);
  136. cout.tie(0);
  137. int T = 1;
  138. auto start1 = high_resolution_clock::now();
  139. while(T--){
  140. AJNJ();
  141. }
  142. auto stop1 = high_resolution_clock::now();
  143. auto duration = duration_cast<microseconds>(stop1 - start1);
  144. cerr << "Time: " << duration . count() / 1000 << " ms" << endl;
  145.  
  146. return 0;
  147. }
Success #stdin #stdout #stderr 0.02s 11116KB
stdin
Standard input is empty
stdout

	
stderr
Time: 8 ms