제출 #1331966

#제출 시각아이디문제언어결과실행 시간메모리
1331966Zone_zoneeSpiderman (COCI20_spiderman)C++20
70 / 70
55 ms10140 KiB
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5;

int n, k, h[N], x, cnt[N], f[N];

int main(){
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>k;
    for (int i=1; i<=n; i++) cin>>h[i], x+=(h[i]>k);
    for (int i=1; i<=n; i++) if (h[i]>k) cnt[h[i]]++;
    for (int i=1; i<N; i++) for (int j=i; j<N; j+=i) f[j]+=cnt[i];
    for (int i=1; i<=n; i++)
    {
        if (h[i]==k) cout<<x<<' ';
        else if (h[i]>k) cout<<f[h[i]-k]-(k==0?1:0)<<' ';
        else cout<<0<<' ';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...