Submission #844283

# Submission time Handle Problem Language Result Execution time Memory
844283 2023-09-05T12:00:16 Z vjudge1 Spiderman (COCI20_spiderman) C++17
70 / 70
54 ms 11532 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+37;
#define int long long


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    int n, k; cin >> n >> k;
    vector<int> x(n);
    vector<int> a(N);
    int f=0;
    for(int i=0; i<n; i++){
        cin >> x[i];

        if(x[i]>k) f++;
        a[x[i]]++;
    }

    for(int l=N-1; l>k; l--){

        for(int j=l*2; j<N; j+=l){
            a[j]+=a[l];
        }

    }


    if(k==0){
        for(int i=0; i<n; i++)
        cout<<a[x[i]]-1<<" ";
    }
    
    else{
        for(int i=0; i<n; i++){
            if(x[i]-k<=k&&x[i]!=k) cout<<0<<" ";
            else if(x[i]==k) cout<<f<<" ";
            else cout<<a[x[i]-k]<<" ";
        }
    }
} 
# Verdict Execution time Memory Grader output
1 Correct 13 ms 8308 KB Output is correct
2 Correct 15 ms 8316 KB Output is correct
3 Correct 27 ms 9336 KB Output is correct
4 Correct 50 ms 11404 KB Output is correct
5 Correct 28 ms 9300 KB Output is correct
6 Correct 51 ms 11532 KB Output is correct
7 Correct 24 ms 9084 KB Output is correct
8 Correct 25 ms 9080 KB Output is correct
9 Correct 54 ms 11344 KB Output is correct
10 Correct 51 ms 11344 KB Output is correct