#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
//#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define vvi vector<vi>
#define vp vector<pii>
#define ppi pair<pii,int>
#define endl '\n'
#define triple tuple<int,int,int>
#define ppp pair<pii,pii>
#define pip pair<int,pii>
#define vpp vector<ppi>
#define sp << " " <<
#define ff first
#define ss second
#define F(xxx,n) for (int xxx=1;xxx<=n;++xxx)
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define pb push_back
const int MOD = 1e9+7;
void solve() {
int n,k;
cin >> n >> k;
vi a(n+1);
F(i,n) cin >> a[i];
vi cnt(2e6+1,0);
F(i,n) cnt[a[i]]++;
vi cur(2e6+1,0);
for (int i=k+1;i<=2000000;i++) {
for (int j=k;j<=2000000;j+=i) cur[j]+=cnt[i];
}
for (int i=1;i<=n;i++) {
cout << cur[a[i]]-(!k) << " ";
}
cout << endl;
}
signed main() {
#ifdef Local
freopen("input.in","r",stdin);
freopen("input.out","w",stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);
int t = 1;
//cin >> t;
while (t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
15960 KB |
Output is correct |
2 |
Correct |
31 ms |
15964 KB |
Output is correct |
3 |
Correct |
41 ms |
16720 KB |
Output is correct |
4 |
Correct |
64 ms |
18256 KB |
Output is correct |
5 |
Correct |
45 ms |
16724 KB |
Output is correct |
6 |
Correct |
67 ms |
18052 KB |
Output is correct |
7 |
Correct |
56 ms |
16716 KB |
Output is correct |
8 |
Correct |
41 ms |
16720 KB |
Output is correct |
9 |
Correct |
71 ms |
18044 KB |
Output is correct |
10 |
Correct |
68 ms |
18000 KB |
Output is correct |