#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pr pair
#define vct vector
#define ins insert
#define pb push_back
#define sz(x) ((int)(x.size()))
const int N = 1e6 + 5;
int b[N];
int c[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k; cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) b[a[i]]++;
for (int i = 1; i < N; i++){
if (i <= k) continue;
for (int j = i; j + k < N; j += i) c[j+k] += b[i];
}
int cnt = 0;
for (int i = 0; i < n; i++){
if (a[i] > k) cnt++;
}
for (int i = 0; i < n; i++){
if (k == 0){
if (a[i] == k){
cout << c[a[i]]+cnt-1 << ' ';
}else{
cout << c[a[i]]-1 << ' ';
}
}else{
if (a[i] == k){
cout << c[a[i]]+cnt << ' ';
}else{
cout << c[a[i]] << ' ';
}
}
}
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
6528 KB |
Output is correct |
2 |
Correct |
15 ms |
5688 KB |
Output is correct |
3 |
Correct |
34 ms |
7476 KB |
Output is correct |
4 |
Correct |
65 ms |
9028 KB |
Output is correct |
5 |
Correct |
39 ms |
8908 KB |
Output is correct |
6 |
Correct |
78 ms |
10436 KB |
Output is correct |
7 |
Correct |
28 ms |
8916 KB |
Output is correct |
8 |
Correct |
31 ms |
8908 KB |
Output is correct |
9 |
Correct |
74 ms |
10304 KB |
Output is correct |
10 |
Correct |
69 ms |
10196 KB |
Output is correct |