Submission #1331962

#TimeUsernameProblemLanguageResultExecution timeMemory
1331962Zone_zoneeSpiderman (COCI20_spiderman)C++20
0 / 70
1 ms580 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+10;

int a[N], f[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        if(a[i] <= k) cnt++;
        f[a[i]]++;
    }
    for(int i = 1; i <= n; ++i){
        if(a[i] == k){
            cout << n-cnt << ' ';
            continue;
        }
        int x = a[i];
        int ans = (a[i]-k > sqrt(x) ? f[(a[i]-k)] : 0);
        for(int j = 1; j <= sqrt(x); ++j){
            if(x%j != k) continue;
            ans += f[j];
            if(a[i] == j) ans--;
            ans += f[x/j];
            if(a[i] == x/j) ans--;
        }
        cout << ans << ' ';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...