# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523856 | tato | Spiderman (COCI20_spiderman) | C++14 | 1150 ms | 12480 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 ll long long
#define pb push_back
using namespace std;
int used[1000001];
int tanr[1000001];
int check(int a, int k)
{
int b = a - k;
int c = sqrt(b);
if(b == 1)
if(k == 0)
if(used[1] > 1)
return used[1] - 1;
else
return 0;
else
return 0;
int cnt = 0;
for(int i = 1; i < c; i++)
{
if(b % i == 0)
{
if(i > k)
cnt += used[i];
int d = b / i;
if (d > k)
cnt += used[d];
}
}
if(c*c == b)
{
if(c > k)
cnt += used[c];
}
else
if(b % c == 0)
{
if(c > k)
cnt += used[c];
int d = b / c;
if (d > k)
cnt += used[d];
}
if(k == 0)
return cnt - 1;
else
return cnt;
}
void answer()
{
int n,x,k,cnt = 0;
vector < int > v,pas;
cin >> n >> k;
for(int i = 1; i <= n; i++)
{
cin >> x;
used[x]++;
v.pb(x);
}
for(int i = 1; i <= 1000001; i++)
if(used[i] != 0)
{
cnt += used[i];
tanr[i] = n - cnt;
}
for(int i = 0; i < v.size(); i++)
{
if(v[i] < k)
pas.pb(0);
if(v[i] == k)
pas.pb(tanr[v[i]]);
if(v[i] > k)
if((v[i] - k) <= k)
pas.pb(0);
else
pas.pb(check(v[i],k));
}
for(int i = 0; i < pas.size(); i++)
cout << pas[i] << ' ';
}
int main()
{
int t = 1;
//cin >> t;
while(t--)
answer();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |