Submission #580923

#TimeUsernameProblemLanguageResultExecution timeMemory
580923AGESpiderman (COCI20_spiderman)C++14
70 / 70
201 ms29352 KiB
#include<bits/stdc++.h> #define F first #define S second #define int long long #define pb push_back using namespace std; const int N=1e6,M=2e3,mod=1e9+7; int a[N],seive[N+10],ans[N],mp[N+10],mp2[N+10]; main() { int n,m; cin>>n>>m; for(int i=0;i<n;i++) cin>>a[i],mp[a[i]]++; for(int i=1;i<=1e6;i++) mp2[i]+=mp[i]+mp2[i-1]; for(int i=1;i<=1e6;i++){ if(i<=m) continue; for(int j=i;j<=1e6;j+=i){ seive[j]+=mp[i]; } } for(int i=0;i<n;i++){ if(a[i]<m) continue; if(a[i]==m){ ans[i]=n-mp2[a[i]]; continue; } if(m==0) ans[i]=seive[a[i]-m]-1; else ans[i]=seive[a[i]-m]; } for(int i=0;i<n;i++) cout<<ans[i]<<" "; cout<<endl; return 0; }

Compilation message (stderr)

spiderman.cpp:11:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 |  main()
      |  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...