# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334023 | ronnith | Spiderman (COCI20_spiderman) | C++14 | 1303 ms | 6380 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>
typedef long long ll;
#define mk make_pair
#define f first
#define s second
using namespace std;
int main(){
int n, k;
scanf("%d%d", &n,&k);
int h[n];
int mx = 0;
for(int i = 0;i < n;i ++){
scanf("%d", &h[i]);
mx = max(mx, h[i]);
}
int fr[mx + 1];
fill(fr, fr + mx + 1, 0);
int cnt = 0;
for(int i = 0;i < n;i ++){
if(h[i] > k){
fr[h[i]] ++;
cnt ++;
}
}
for(int i = 0;i < n;i ++){
int fac = h[i] - k;
if(fac == 0){
printf("%d ", cnt);
} else if(fac > 0){
int ans = 0;
for(int j = 1;j * j <= fac;j ++){
if(fac % j == 0){
ans += fr[j];
if(j * j != fac)ans += fr[fac / j];
}
}
if(fac % h[i] == 0)ans --;
printf("%d ", ans);
} else {
printf("0 ");
}
}
puts("");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |