#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e6 + 5;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define OPEN freopen(".in", "r", stdin); \
freopen(".out", "w", stdout);
#else
#define OPEN void(23);
#endif
int sieve[MAXN];
int cnts[MAXN];
void solve()
{
int n, k; cin >> n >> k;
vector <int> vec(n);
for(int &i : vec) cin >> i, cnts[i]++;
for(int i = k +1; i < MAXN; i++)
{
for(int j = 0; j + k < MAXN; j += i)
sieve[j + k] += cnts[i];
}
for(int &i : vec) cout << (sieve[i] - (k == 0)) << " ";
return;
}
int32_t main()
{
OPEN;
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1; //cin >> t;
while(t--)
{
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
15960 KB |
Output is correct |
2 |
Correct |
13 ms |
15964 KB |
Output is correct |
3 |
Correct |
27 ms |
17156 KB |
Output is correct |
4 |
Correct |
52 ms |
19212 KB |
Output is correct |
5 |
Correct |
31 ms |
17240 KB |
Output is correct |
6 |
Correct |
50 ms |
19280 KB |
Output is correct |
7 |
Correct |
26 ms |
16976 KB |
Output is correct |
8 |
Correct |
26 ms |
16976 KB |
Output is correct |
9 |
Correct |
52 ms |
19024 KB |
Output is correct |
10 |
Correct |
50 ms |
18948 KB |
Output is correct |