Submission #1182093

#TimeUsernameProblemLanguageResultExecution timeMemory
118209312345678Spiderman (COCI20_spiderman)C++20
70 / 70
50 ms10312 KiB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e6+5;

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

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<nx; i++) for (int j=i; j<nx; 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...