Submission #644296

#TimeUsernameProblemLanguageResultExecution timeMemory
644296emad234Spiderman (COCI20_spiderman)C++17
70 / 70
1079 ms14876 KiB
#include <bits/stdc++.h> #define all(v) ((v).begin(),(v).end()) using namespace std; #define int long long const int mod = 1e9 + 7; const int mxN = 2e6 + 1; int a[mxN]; int fr[mxN]; int ans[mxN]; int gr[mxN]; signed main() { cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(0); int n,k; cin >>n>>k; int num = 0; for(int i = 0;i < n;i++){ cin >>a[i]; if(a[i] > k) num++; fr[a[i]]++; } for(int i = 0;i < n;i++){ if(a[i] > k){ int x = a[i] - k; for(int j = 1;j * j <= x;j++){ if(x % j == 0){ if(j > k && j){ if(j == a[i]) ans[i] += fr[j] - 1; else ans[i] += fr[j]; } if(x / j > k && x/ j != j){ if(x / j == a[i]) ans[i] += fr[x / j] - 1; else ans[i] += fr[x / j]; } } } }else if(a[i] == k){ ans[i] = num; } cout<<ans[i]<<' '; } }
#Verdict Execution timeMemoryGrader output
Fetching results...