#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 1e6 + 1;
int cnt[M],ans[M];
signed main()
{
int n,k;
cin>>n>>k;
int a[n];
for (int i=0;i<n;i++)
{
cin>>a[i];
cnt[a[i]]++;
}
for (int i=k+1;i<M;i++)
for (int j=k;j<M;j+=i)
ans[j]+=cnt[i]-(i==j);
for (int i=0;i<n;i++)
cout<<ans[a[i]]<<' ';
cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11100 KB |
Output is correct |
2 |
Correct |
26 ms |
10016 KB |
Output is correct |
3 |
Correct |
48 ms |
12936 KB |
Output is correct |
4 |
Correct |
89 ms |
15444 KB |
Output is correct |
5 |
Correct |
57 ms |
17368 KB |
Output is correct |
6 |
Correct |
101 ms |
20560 KB |
Output is correct |
7 |
Correct |
47 ms |
17496 KB |
Output is correct |
8 |
Correct |
60 ms |
17416 KB |
Output is correct |
9 |
Correct |
101 ms |
20304 KB |
Output is correct |
10 |
Correct |
101 ms |
20356 KB |
Output is correct |