# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580923 | AGE | Spiderman (COCI20_spiderman) | C++14 | 201 ms | 29352 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |