# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40762 | ssnsarang2023 | Gap (APIO16_gap) | C++14 | 0 ms | 0 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;
ll findGap(int _t, int _n) {
ll n = _n;
ll mn = 1, mx = (ll)1e18;
MinMax(mn, mx, mn, mx);
ll d = (mx - mn) / n, mod = (mx - mn) % n, pre = mn;
ll pstep = mn, step = mn + d + - 1 + mod, gap = 0;
while (1) {
ll mntmp = -1, mxtmp = -1;
if (pstep <= min(mx - 1, step)) MinMax(pstep + 1, min(mx - 1, step), mntmp, mxtmp);
if (step >= mx) {
if (mxtmp != -1) gap = max(gap, mx - mxtmp);
else gap = max(gap, mx - pre);
} else if (mntmp != -1) gap = max(gap, mntmp - pre);
pre = mxtmp, pstep = step, step += d;
}
return gap;
}