#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int MAX = 1e6 + 10;
int n, k, v[MAX];
int resp[MAX], freq[MAX];
int32_t main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for(int i = 1; i <= n; i++)
{
cin >> v[i];
freq[ v[i] ]++;
}
for(int i = 1; i < MAX; i++)
for(int j = 0; j * i + k < MAX; j++)
if(k < i) resp[j * i + k] += freq[i];
for(int i = 1; i <= n; i++)
cout << resp[ v[i] ] + (k == 0 ? -1 : 0) << ' ';
cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
11096 KB |
Output is correct |
2 |
Correct |
23 ms |
9820 KB |
Output is correct |
3 |
Correct |
32 ms |
12380 KB |
Output is correct |
4 |
Correct |
52 ms |
14420 KB |
Output is correct |
5 |
Correct |
36 ms |
16976 KB |
Output is correct |
6 |
Correct |
62 ms |
19276 KB |
Output is correct |
7 |
Correct |
37 ms |
16980 KB |
Output is correct |
8 |
Correct |
39 ms |
16976 KB |
Output is correct |
9 |
Correct |
59 ms |
19028 KB |
Output is correct |
10 |
Correct |
59 ms |
19036 KB |
Output is correct |