#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define f first
#define s second
#define tii tuple<int,int>
#define time timee
using namespace std;
const int N = 300005;
map<ll,ll>mp;
ll ar[N+3],n,k;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>k;
int ans=0;
for(int i=1;i<=n;i++){
cin>>ar[i];
if(ar[i]<=k)--ans;
mp[ar[i]]=0;
}
for(int i=k+1;i<=1e6;i++){
if(!mp.count(i))continue;
for(int j=i;j<=1e6+5;j+=i){
if(j+k<=1e6)if(mp.count(j+k))++mp[j+k];
}
}
for(int i=1;i<=n;i++){
if(ar[i]==k)cout<<ans+n<<" ";
else cout<<mp[ar[i]]<<" ";
}
return 0;
}
/*
5 1
1 3 5 7 2
6 3
4 3 12 6 8 2
*/
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |