#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, A = 1e6 + 10;
int n, k, a[N], cnt[A], ans[A];
int main(){
cin >> n >> k;
for (int i = 0; i < n; i ++)
cin >> a[i], cnt[a[i]]++;
for (int i = 0; i < n; i ++){
if (cnt[a[i]] == 0 or k >= a[i]) continue;
for (int r = k; r <= 1e6; r += a[i])
ans[r] += cnt[a[i]];
cnt[a[i]] = 0;
}
for (int i = 0; i < n; i ++)
cout << ans[a[i]] - (k == 0) << " ";
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
6488 KB |
Output is correct |
2 |
Correct |
7 ms |
5724 KB |
Output is correct |
3 |
Correct |
29 ms |
7380 KB |
Output is correct |
4 |
Correct |
87 ms |
8640 KB |
Output is correct |
5 |
Correct |
38 ms |
8784 KB |
Output is correct |
6 |
Correct |
89 ms |
10320 KB |
Output is correct |
7 |
Correct |
34 ms |
8792 KB |
Output is correct |
8 |
Correct |
39 ms |
8784 KB |
Output is correct |
9 |
Correct |
87 ms |
10064 KB |
Output is correct |
10 |
Correct |
94 ms |
9968 KB |
Output is correct |