fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4. #define double long double
  5. #define print(a) for(auto x : a) cout << x << " "; cout << endl
  6.  
  7.  
  8. const int M = 1000000007;
  9. const int INF = 2e9+1;
  10. const int LINF = 2000000000000000001;
  11.  
  12. inline int power(int a, int b, int mod=M) {
  13. int x = 1;
  14. a %= mod;
  15. while (b) {
  16. if (b & 1) x = (x * a) % mod;
  17. a = (a * a) % mod;
  18. b >>= 1;
  19. }
  20. return x;
  21. }
  22.  
  23.  
  24. //_ ***************************** START Below *******************************
  25.  
  26.  
  27. const int N = 10000007;
  28.  
  29.  
  30. vector<int> spf;
  31. vector<int> primes;
  32.  
  33. void seive(){
  34. spf.assign(N+1, 0);
  35. for(int i=2; i<=N; i++) spf[i] = i;
  36.  
  37. for(int i=2; i*i<=N; i++){
  38. if(spf[i] != i) continue;
  39. for(int j=i*i; j<=N; j+=i){
  40. spf[j] = min(spf[j], i);
  41. }
  42. }
  43. for(int i=2; i<=N; i++){
  44. if(spf[i] == i) primes.push_back(i);
  45. }
  46. }
  47.  
  48.  
  49. vector<int> a;
  50.  
  51. vector<int> consistency(int n, int m){
  52.  
  53. unordered_map<int,int> mp;
  54. int d = 1;
  55. for(auto& q : primes){
  56. int p = q;
  57. int e = 0;
  58.  
  59. while(m/p>0){
  60. e += m/p;
  61. p *= q;
  62. }
  63. mp[q] = e;
  64. d = (d * (e+1))%M;
  65. }
  66.  
  67.  
  68. vector<int> ans;
  69. for(auto& it : a){
  70. int x = it;
  71.  
  72. int val = d;
  73.  
  74. while(x>1){
  75.  
  76. int p = spf[x];
  77. int e = 0;
  78.  
  79. while(x % p == 0){
  80. e++;
  81. x /= p;
  82. }
  83.  
  84. int de = mp[p];
  85.  
  86. int nmr = (e+de+1)%M;
  87. int dnr = power(de+1, M-2);
  88.  
  89. val = (val * ( (nmr * dnr)%M) ) % M;
  90.  
  91. }
  92.  
  93. ans.push_back(val);
  94. }
  95.  
  96. return ans;
  97.  
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. vector<int> practice(int n, int m){
  116.  
  117.  
  118. }
  119.  
  120.  
  121.  
  122.  
  123.  
  124. void solve() {
  125. static int _ = (seive(), 0);
  126.  
  127. int n, m;
  128. cin>> n >> m;
  129.  
  130. a.resize(n);
  131. for(int i=0; i<n; i++) cin >> a[i];
  132.  
  133. auto ans = consistency(n, m);
  134.  
  135. for(auto& it : ans) cout << it << " "; cout << endl;
  136.  
  137.  
  138. }
  139.  
  140.  
  141.  
  142.  
  143.  
  144. int32_t main() {
  145. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  146.  
  147. int t = 1;
  148. // cin >> t;
  149. while (t--) {
  150. solve();
  151. }
  152.  
  153. return 0;
  154. }
Success #stdin #stdout 0.39s 115944KB
stdin
3 3
1 2 3
stdout
4 6 6