#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
const int MAXN = 3e5 + 10;
int a[MAXN], ans[1000001], cnt[1000001];
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int n,k;cin >> n >> k;
rep(i,1,n) cin >> a[i];
rep(i,1,n) cnt[a[i]]++;
rep(y,k+1,1000) {
if (!cnt[y]) continue;
rep(i,1,n) {
if (a[i]%y==k) ans[a[i]]+=cnt[y];
}
}
rep(i,1,n) {
if (a[i] > 1000) {
for (int y = k; y <= 1000000; y += a[i]) {
ans[y]++;
}
}
}
rep(i,1,n) cout << ans[a[i]]-(k==0) << " \n"[i==n];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |