fork download
  1. #include<bits/stdc++.h>
  2.  
  3. #define LLU unsigned long long
  4. #define ll long long
  5. #define pi 3.141592
  6. #define nl printf("\n")
  7. #define f(i,l1,l2) for(i=l1;i<l2;i++)
  8. #define gc getchar_unlocked
  9. #define vi vector<int>
  10. #define vit vi::iterator
  11. #define all(c) c.begin(), c.end()
  12. #define pb push_back
  13. #define endl "\n"
  14. #define mp make_pair
  15. #define mod 1000000007
  16. using namespace std;
  17.  
  18. /*void fin(int &x) //does not compile in codeblocks but does in online judges
  19. { //use if input too large ( only for integers )
  20. int i=0;x=0;
  21. register int c=gc();
  22. while(c<48||c>57)
  23. c=gc();
  24. while(c>47&&c<58)
  25. {
  26. x=(x<<1)+(x<<3) + c-48;
  27. i++;
  28. c=gc();
  29. }
  30. }*/
  31.  
  32. ll gcd(ll m, ll n)
  33. {
  34. if(n==0)
  35. return m;
  36. return gcd(n,m%n);
  37. }
  38.  
  39. LLU mod_pow(LLU base, LLU exp)
  40. {
  41. LLU res=1;
  42. while (exp>0)
  43. {
  44. if (exp%2==1)
  45. res=(res*base)%mod;
  46. exp=exp>>1;
  47. base =(base*base)%mod;
  48. }
  49. return res;
  50. }
  51.  
  52. int main()
  53. {
  54. std::ios::sync_with_stdio(false);
  55. cin.tie(0);
  56. int t,i,j,n,e;
  57. cin>>n;
  58. int a[n+5];
  59. int c[n+5];
  60. f(i,0,n)
  61. {
  62. cin>>a[i];
  63. c[i] = a[i];
  64. }
  65. sort(a,a+n);
  66. map<int,int> h;
  67. f(i,0,n)
  68. {
  69. if(h.find(a[i])==h.end()){
  70. f(j,i+1,n)
  71. {
  72. if(a[j]%a[i]==0)
  73. h[a[i]]+=1;
  74. }
  75. }
  76. }
  77. ll ans = 0;
  78. f(i,0,n)
  79. {
  80. int x = h[c[i]];
  81. //cout<<x;
  82. ans = mod_pow(2,x+1);
  83. ans%=mod;
  84. ans = (ans-1+mod)%mod;
  85. cout<<ans<<" ";
  86. }
  87.  
  88. return 0;
  89. }
  90.  
  91.  
Runtime error #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Standard output is empty