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