| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1273582 | SmuggingSpun | Spiderman (COCI20_spiderman) | C++20 | 706 ms | 120964 KiB |
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
const int lim = 1e6 + 5;
int n, k, f[lim];
vector<int>d[lim];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> k;
memset(f, 0, sizeof(f));
for(int i = 1; i < lim; i++){
for(int j = i; j < lim; j += i){
d[j].emplace_back(i);
}
}
vector<int>a(n);
for(int& x : a){
cin >> x;
f[x]++;
}
for(int i = 1; i < lim; i++){
f[i] += f[i - 1];
}
for(int& x : a){
if(x <= k){
cout << (x == k ? n - f[x] : 0) << " ";
continue;
}
int ans = 0;
for(int& y : d[x - k]){
if(y > k){
ans += f[y] - f[y - 1];
}
}
cout << ans << " ";
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
