fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define endl '\n'
  4. #define int long long
  5. const int MOD = pow(10,9)+7;
  6. const int MOD2 = 998244353;
  7. const int INF = LLONG_MAX/2;
  8.  
  9. int primes[1000000];
  10.  
  11. void seive(){
  12. fill(primes, primes + 1000000, 1);
  13. primes[0] = primes[1] = 0;
  14. for(int i = 2 ; i*i < 1000000 ; i++){
  15. if(primes[i]){
  16. for(int j = i*i ; j < 1000000 ; j += i){
  17. primes[j] = 0;
  18. }
  19. }
  20. }
  21. }
  22. int factorial(int n){
  23. if(n==0){
  24. return 1;
  25. }
  26. return (n*(factorial(n-1)))%MOD;
  27. }
  28. bool isPrime(int n){
  29. if(n <= 1) return false;
  30. for(int i = 2 ; i*i <= n ; i++){
  31. if(n % i == 0) return false;
  32. }
  33. return true;
  34. }
  35.  
  36. int power(int a, int b){
  37. if(b == 0) return 1;
  38. a %= MOD;
  39. int value = power(a, b / 2);
  40. if(b % 2 == 0){
  41. return (value * value) % MOD;
  42. } else {
  43. return ((value * value) % MOD * (a % MOD)) % MOD;
  44. }
  45. }
  46.  
  47. int gcd(int a, int b){
  48. if(a == 0) return b;
  49. return gcd(b % a, a);
  50. }
  51. void dfs(int node , vector<int>A[] , int visited[] , int sum[] , int parent[] , int values[]){
  52. visited[node] = 1;
  53. for(auto node1 : A[node]){
  54. if(!visited[node1]){
  55. parent[node1] = node;
  56. dfs(node1,A,visited,sum,parent,values);
  57. }
  58. }
  59. int s = 0;
  60. for(auto node1 : A[node]){
  61. if(parent[node]!=node1){
  62. s = max(s,sum[node1]);
  63. }
  64. }
  65. sum[node] = values[node]+s;
  66. }
  67. int spf[1000001];
  68. void SPF(){
  69. for(int i = 2 ; i<=1000000 ; i++){
  70. spf[i] = i;
  71. }
  72. for(int i = 2 ; i<=sqrt(1000000) ; i++){
  73. if(spf[i]==i){
  74. for(int j = i*i ; j<=1000000 ; j+=i){
  75. if(spf[j]==j){
  76. spf[j] = i;
  77. }
  78. }
  79. }
  80. }
  81. }
  82. void solve() {
  83. int n,m;
  84. cin>>n>>m;
  85. int A[n];
  86. for(int i = 0 ; i<n ; i++){
  87. cin>>A[i];
  88. }
  89. unordered_map<int,int>m1;
  90. for(int i = 1 ; i<=m ; i++){
  91. int d = i;
  92. while(d!=1){
  93. m1[spf[d]]++;
  94. d /= spf[d];
  95. }
  96. }
  97. for(int i = 0 ; i<n ; i++){
  98. unordered_map<int,int>m2 = m1;
  99. int d = A[i];
  100. while(d!=1){
  101. m2[spf[d]]++;
  102. d /= spf[d];
  103. }
  104. int g = 1;
  105. for(auto j:m2){
  106. g = ((g%MOD)*((j.second+1)%MOD))%MOD;
  107. }
  108. cout<<g<<" ";
  109. }
  110. cout<<endl;
  111. }
  112.  
  113. signed main(){
  114. ios::sync_with_stdio(false); cin.tie(NULL);
  115. SPF();
  116. //int t;
  117. //cin >> t;
  118. //while(t--){
  119. solve();
  120. //}
  121. return 0;
  122. }
Success #stdin #stdout 0.02s 11752KB
stdin
3 3
1 2 3
stdout
4 6 6