#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N =1e6 + 23;
const ll inf = 1e18;
#define F first
#define S second
#define pb push_back
#define kill(x) cout<<x<<endl, exit(0);
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lc (v << 1)
#define rc ((v<<1) |1)
int n,k;
int a[N];
int cnt[N];
vector<int> vals;
int ans[N];
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin>>n>>k;
for(int i = 0 ; i < n ; i ++) {
int x; cin>>x;
cnt[x] ++;
a[i] = x;
vals.pb(x);
}
sort(all(vals));
vals.resize(unique(all(vals)) - vals.begin());
for(int x : vals) {
if(k >= x) continue;
for(int y = k; y < N; y += x) {
ans[y] += cnt[x];
}
}
for(int i = 0 ; i< n ; i++) {
cout<<ans[a[i]] - (k == 0) << ' ';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8796 KB |
Output is correct |
2 |
Correct |
5 ms |
8664 KB |
Output is correct |
3 |
Correct |
22 ms |
10208 KB |
Output is correct |
4 |
Correct |
52 ms |
14848 KB |
Output is correct |
5 |
Correct |
28 ms |
10196 KB |
Output is correct |
6 |
Correct |
64 ms |
14796 KB |
Output is correct |
7 |
Correct |
33 ms |
10204 KB |
Output is correct |
8 |
Correct |
25 ms |
10196 KB |
Output is correct |
9 |
Correct |
68 ms |
14872 KB |
Output is correct |
10 |
Correct |
65 ms |
14716 KB |
Output is correct |