# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339954 | Hazem | Spiderman (COCI20_spiderman) | C++14 | 1865 ms | 126832 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.
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/
#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
const int N = 1e6 + 10;
LL LINF = 100000000000000000;
LL INF = 1000000000;
vector<int>vec[N];
int freq[N],a[N],pr[N];
int main()
{
//freopen("out.txt","w",stdout);
int n,k,mx = 0;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]),mx = max(mx,a[i]),freq[a[i]]++;
for(int i=1;i<=mx;i++){
pr[i] = pr[i-1]+freq[i];
for(int j=i;j<=mx;j+=i)
vec[j].push_back(i);
}
for(int i=1;i<=n;i++){
int ans = a[i]==k?n-pr[a[i]]:0;
if(a[i]>k)
for(auto x:vec[a[i]-k])
ans += freq[x]*(a[i]%x==k);
printf("%d ",ans-(!k));
}
puts("");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |