fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4.  
  5. const ll mx=1000000;
  6. vector<ll> spf(mx+1);
  7.  
  8. void cspf() {
  9. for(ll x=2;x<=mx;x++) spf[x]=x;
  10. for(ll x=2;x*x<=mx;x++) {
  11.  
  12. if(spf[x]==x) {
  13. for(ll y=x*x;y<=mx;y+=x) {
  14.  
  15. if(spf[y]==y) spf[y]=x;
  16. }
  17. }
  18.  
  19.  
  20. }
  21. }
  22.  
  23. unordered_map<ll,ll> cl(ll v) {
  24. unordered_map<ll,ll> a;
  25. while(v!=1) {
  26. ll d=spf[v];
  27.  
  28. a[d]++;
  29. v/=d;
  30.  
  31.  
  32. }
  33. return a;
  34. }
  35.  
  36. int main() {
  37. ll n,m;
  38. cin>>n>>m;
  39.  
  40. unordered_map<ll,ll> b;
  41.  
  42. cspf();
  43. ll md=1e9+7;
  44. for(ll i=2;i<=m;i++) {
  45. unordered_map<ll,ll> a=cl(i);
  46.  
  47. for(auto it=a.begin();it!=a.end();++it) {
  48. b[it->first]+=it->second;
  49.  
  50. }
  51. }
  52.  
  53. ll arr[n+1]={0};
  54. for(ll i=1;i<=n;i++) {
  55. unordered_map<ll,ll> b5=b;
  56. ll g=1;
  57.  
  58. cin>>arr[i];
  59. unordered_map<ll,ll> a=cl(arr[i]);
  60.  
  61. for(auto it=a.begin();it!=a.end();++it)
  62. {
  63.  
  64. b5[it->first]+=it->second;
  65.  
  66. }
  67. for(auto it=b5.begin();it!=b5.end();++it) {
  68. g=(g*((it->second+1)%md))%md;
  69.  
  70. }
  71. cout<<g<<" ";
  72. }
  73. return 0;
  74. }
  75.  
Success #stdin #stdout 0.02s 10792KB
stdin
3 3
1 2 3
stdout
4 6 6