Submission #1321314

#TimeUsernameProblemLanguageResultExecution timeMemory
1321314nathako9nSpiderman (COCI20_spiderman)C++20
14 / 70
73 ms11520 KiB
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define f first #define s second #define tii tuple<int,int> #define time timee using namespace std; const int N = 300005; const int MAXV = 1000000; int cnt[MAXV + 5]; int res[MAXV + 5]; ll ar[N+3],n,k; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>k; for(int i=1;i<=n;i++){ cin>>ar[i]; cnt[ar[i]]++; } for(int i=k+1;i<=MAXV;i++){ if(cnt[i] == 0) continue; for(int j=i; j+k<=MAXV; j+=i){ if(cnt[j+k] > 0) res[j+k] += cnt[i]; } } for(int i=1;i<=n;i++){ int ans = res[ar[i]]; if(k == 0) ans--; cout<<ans<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...