#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define crep(i,x,n) for(ll i=x;i<n;i++)
#define drep(i,n) for(ll i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<ll,ll>;
using vi=vector<ll>;
using vll=vector<long long>;
const ll _n=1e6+10;
int main(){
_3qplfh5;
ll n,k;
cin>>n>>k;
vi a(n);
rep(i,n){
cin>>a[i];
}
ll ma=*max_element(all(a));
vi cnt(_n);
rep(i,n){
cnt[a[i]]++;
}
vi oa=a;
sort(all(a));
a.erase(unique(all(a)),a.end());
vi pans(_n,0);
rep(i,sz(a)){
ll ai=a[i];
ll x=0;
while(x<=_n){
if(x+k<x+ai and x+k<_n){
pans[x+k]+=cnt[ai];
}
x+=ai;
}
}
rep(i,n){
cout<<pans[oa[i]]<<" ";
}
cout<<"\n";
//
return 0;
}
Compilation message
spiderman.cpp: In function 'int main()':
spiderman.cpp:29:5: warning: unused variable 'ma' [-Wunused-variable]
29 | ll ma=*max_element(all(a));
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
15948 KB |
Output is correct |
2 |
Correct |
24 ms |
16124 KB |
Output is correct |
3 |
Correct |
45 ms |
17812 KB |
Output is correct |
4 |
Correct |
79 ms |
21604 KB |
Output is correct |
5 |
Incorrect |
77 ms |
17780 KB |
Output isn't correct |
6 |
Incorrect |
119 ms |
21480 KB |
Output isn't correct |
7 |
Correct |
71 ms |
17672 KB |
Output is correct |
8 |
Correct |
72 ms |
17668 KB |
Output is correct |
9 |
Correct |
118 ms |
21408 KB |
Output is correct |
10 |
Correct |
116 ms |
21352 KB |
Output is correct |