#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 3e6+10;
int cnt[mxn],ans[mxn];
int n,k;
int arr[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>k;
for(int i = 1;i<=n;i++){
cin>>arr[i];
cnt[arr[i]]++;
}
for(int i = 1;i<mxn/2;i++){
if(i<=k)continue;
for(int j = 0;j*i+k<mxn;j++){
ans[i*j+k] += cnt[i];
}
if(!k)ans[i]--;
}
for(int i = 1;i<=n;i++)cout<<ans[arr[i]]<<' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
18780 KB |
Output is correct |
2 |
Correct |
30 ms |
18780 KB |
Output is correct |
3 |
Correct |
50 ms |
21328 KB |
Output is correct |
4 |
Correct |
66 ms |
22100 KB |
Output is correct |
5 |
Correct |
58 ms |
21332 KB |
Output is correct |
6 |
Correct |
73 ms |
21948 KB |
Output is correct |
7 |
Correct |
42 ms |
21304 KB |
Output is correct |
8 |
Correct |
44 ms |
21584 KB |
Output is correct |
9 |
Correct |
78 ms |
21900 KB |
Output is correct |
10 |
Correct |
66 ms |
21664 KB |
Output is correct |