# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
644296 | emad234 | Spiderman (COCI20_spiderman) | C++17 | 1079 ms | 14876 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 all(v) ((v).begin(),(v).end())
using namespace std;
#define int long long
const int mod = 1e9 + 7;
const int mxN = 2e6 + 1;
int a[mxN];
int fr[mxN];
int ans[mxN];
int gr[mxN];
signed main()
{
cin.tie(0);cout.tie(0);
ios_base::sync_with_stdio(0);
int n,k;
cin >>n>>k;
int num = 0;
for(int i = 0;i < n;i++){
cin >>a[i];
if(a[i] > k)
num++;
fr[a[i]]++;
}
for(int i = 0;i < n;i++){
if(a[i] > k){
int x = a[i] - k;
for(int j = 1;j * j <= x;j++){
if(x % j == 0){
if(j > k && j){
if(j == a[i])
ans[i] += fr[j] - 1;
else
ans[i] += fr[j];
}
if(x / j > k && x/ j != j){
if(x / j == a[i])
ans[i] += fr[x / j] - 1;
else
ans[i] += fr[x / j];
}
}
}
}else if(a[i] == k){
ans[i] = num;
}
cout<<ans[i]<<' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |