Submission #891225

#TimeUsernameProblemLanguageResultExecution timeMemory
891225HADI_TSpiderman (COCI20_spiderman)C++17
70 / 70
1045 ms18008 KiB
#include<bits/stdc++.h> #define int long long #define pb(x) push_back(x) #define in(x) insert(x) #define F first #define S second #define endl '\n' #define yes cout<<"YES"<<endl; #define no cout<<"NO"<<endl; const int M=1e9+7; const int N=1e6+10; using namespace std; int freq[N]; int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n,c; cin>>n>>c; int a[n+10] , ans[n+10]={0} , b[n+10]; for(int i=1;i<=n;i++){ cin>>a[i]; b[i] = a[i]; freq[a[i]]++; } for(int i=1;i<=n;i++) { int cur = a[i] - c; for(int j=1;j*j<=cur;j++) { if(cur % j == 0) { int f = j , s = cur/j; if(cur + f > a[i]) ans[i] += freq[f] - (f == a[i]); if(cur + s > a[i]){ if(f != s) ans[i] += freq[s] - (s == a[i]); } } } } sort(a+1,a+1+n); int idx = n; for(int i=n;i>=1;i--) { if(a[i] == c) { idx = i; break; } } for(int i=1;i<=n;i++){ if(b[i] == c) ans[i] += n-idx; cout<<ans[i]<<' '; } }
#Verdict Execution timeMemoryGrader output
Fetching results...