#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
long long n, k, arr[N], cnt[N], ans[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> arr[i];
cnt[arr[i]]++;
}
for(int i = k + 1; i < N; i++){
for(int j = k; j < N; j += i){
ans[j] += cnt[i] - (i == j);
}
}
for(int i = 1; i <= n; i++) cout << ans[arr[i]] << " ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
11092 KB |
Output is correct |
2 |
Correct |
47 ms |
9812 KB |
Output is correct |
3 |
Correct |
71 ms |
12340 KB |
Output is correct |
4 |
Correct |
90 ms |
14456 KB |
Output is correct |
5 |
Correct |
72 ms |
17076 KB |
Output is correct |
6 |
Correct |
103 ms |
19212 KB |
Output is correct |
7 |
Correct |
58 ms |
16884 KB |
Output is correct |
8 |
Correct |
61 ms |
16888 KB |
Output is correct |
9 |
Correct |
107 ms |
19004 KB |
Output is correct |
10 |
Correct |
103 ms |
19028 KB |
Output is correct |