#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
int n, k;
int cnt[N],ans[N];
void seive (){
for(int i=k+1;i<N;i++)
for(int j=k;j<N;j+=i)
ans[j] += cnt[i];
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>k;
vector<int>a(n);
for(auto&it:a){
cin>>it;
cnt[it]++;
}
seive();
for(int i=0;i<n;i++)
cout<<ans[a[i]]-(k==0)<<' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
6484 KB |
Output is correct |
2 |
Correct |
17 ms |
5676 KB |
Output is correct |
3 |
Correct |
41 ms |
7260 KB |
Output is correct |
4 |
Correct |
66 ms |
8764 KB |
Output is correct |
5 |
Correct |
34 ms |
8780 KB |
Output is correct |
6 |
Correct |
76 ms |
10188 KB |
Output is correct |
7 |
Correct |
33 ms |
8652 KB |
Output is correct |
8 |
Correct |
30 ms |
8876 KB |
Output is correct |
9 |
Correct |
64 ms |
9968 KB |
Output is correct |
10 |
Correct |
85 ms |
10060 KB |
Output is correct |