#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 1000005
using namespace std;
vector <int> cnt(N), ans(N), values, arr(N);
int32_t main(){
fast
int n, k;
cin>>n>>k;
for(int i = 0; i < n; i++) {
cin>>arr[i];
int in = arr[i];
if(!cnt[in]) {
values.push_back(in);
}
cnt[in]++;
}
sort(values.begin(), values.end());
reverse(values.begin(), values.end());
//k kalanını unutma
for(auto val:values) {
//cout<<val<<":\n";
if(k == 0) {
ans[val] += cnt[val] - 1;
}
if(k >= val) continue;
for(int i = 0; i <= values[0] - k; i += val) {
if(i + k == val) continue;
ans[i + k] += cnt[val];
}
}
for(int i = 0; i < n; i++) {
cout<<ans[arr[i]]<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
23900 KB |
Output is correct |
2 |
Correct |
12 ms |
23900 KB |
Output is correct |
3 |
Correct |
26 ms |
24156 KB |
Output is correct |
4 |
Correct |
46 ms |
24912 KB |
Output is correct |
5 |
Correct |
46 ms |
25052 KB |
Output is correct |
6 |
Correct |
78 ms |
25480 KB |
Output is correct |
7 |
Correct |
42 ms |
25052 KB |
Output is correct |
8 |
Correct |
44 ms |
25048 KB |
Output is correct |
9 |
Correct |
92 ms |
25548 KB |
Output is correct |
10 |
Correct |
68 ms |
25300 KB |
Output is correct |