/*
ID: antwand1
TASK: barn1
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define du long double
#define F first
#define S second
using namespace std;
const int N=1e6+100;
int a[N];
int ar[N];
int ans[N];
main()
{
//freopen("barn1.in","r",stdin);freopen("barn1.out","w",stdout);
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++){
int b;
cin>>b;
ar[i]=b;
a[b]++;
}
for(int i=1;i<=1e6;i++){
if(a[i]&&k<=i-1){
for(int j=0;j*i<=1e6;j++){
// cout<<i<<" "<<j<<"\n";
ans[j*i+k]+=a[i];
}
}
}
// cout<<endl;
if(k==0){
for(int i=1;i<=1e6;i++)ans[i]--;
}
//for(int i=1;i<=12;i++)cout<<ans[i]<<" ";cout<<endl;
for(int i=1;i<=n;i++){
cout<<ans[ar[i]]<<" ";
}
//cout<<endl;
}
Compilation message
spiderman.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
16 | main()
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
6636 KB |
Output is correct |
2 |
Correct |
11 ms |
5740 KB |
Output is correct |
3 |
Correct |
56 ms |
7916 KB |
Output is correct |
4 |
Correct |
145 ms |
10476 KB |
Output is correct |
5 |
Correct |
83 ms |
9452 KB |
Output is correct |
6 |
Correct |
174 ms |
12268 KB |
Output is correct |
7 |
Correct |
73 ms |
9452 KB |
Output is correct |
8 |
Correct |
79 ms |
9452 KB |
Output is correct |
9 |
Correct |
184 ms |
12012 KB |
Output is correct |
10 |
Correct |
179 ms |
12012 KB |
Output is correct |