Submission #1185727

#TimeUsernameProblemLanguageResultExecution timeMemory
1185727MoonnSpiderman (COCI20_spiderman)C++20
70 / 70
1309 ms19204 KiB
#pragma GCC optimize("O3")//thanks to Raul :) #include<bits/stdc++.h>// #define ll long long #define endl "\n" #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const ll sz=3e5+23;// bool comp(pair<string,ll>&a,pair<string,ll>&b) { if(a.second==b.second) return a.first<b.first; return a.second>b.second; } void solve() { ll n,k,i,j,say=0; cin>>n>>k; ll a[n]; map<ll,ll>mp; for(i=0;i<n;i++) { cin>>a[i]; mp[a[i]]++; if(a[i]>k) say++; } for(i=0;i<n;i++) { if(a[i]==k) { cout<<say<<' '; continue; } if(k>a[i]) { cout<<0<<' '; continue; } ll co=0; ll nw=a[i]-k; for(j=2;j<=sqrt(nw);j++) { if(nw%j==0) { if(j>k and a[i]%j==k) co+=mp[j]; ll x=nw/j; if(x!=j and x>k and a[i]%x==k) co+=mp[x]; } } // cout<<co<<"--"; if(a[i]%nw==k) co+=mp[nw]; if(1!=nw and a[i]%1==k) co+=mp[1]; if(nw==a[i] and a[i]%nw==k) co--; if(nw!=1 and a[i]==1 and a[i]%1==k) co--; cout<<co<<" "; } cout<<endl; } int main() { AI //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ll t=1; // cin>>t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...