#include <bits/stdc++.h>
using namespace std;
const int nx=1e6+5;
int n, k, h[nx], x, cnt[nx], f[nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>k;
for (int i=1; i<=n; i++) cin>>h[i], x+=(h[i]>k);
for (int i=1; i<=n; i++) if (h[i]>k) cnt[h[i]]++;
for (int i=1; i<nx; i++) for (int j=i; j<nx; j+=i) f[j]+=cnt[i];
for (int i=1; i<=n; i++)
{
if (h[i]==k) cout<<x<<' ';
else if (h[i]>k) cout<<f[h[i]-k]-(k==0?cnt[h[i]-k]:0)<<' ';
else cout<<0<<' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |