# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17846 | Elibay | Odd-even (IZhO11_oddeven) | C++14 | 0 ms | 1716 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>
using namespace std;
unsigned long long n, l = 0, r = 1e18 + 1, x, w;
int main ()
{
#ifdef Elibay
freopen (".in", "r", stdin);
#endif
cin >> n;
while (l <= r)
{
unsigned long long m = (l + r) >> 1;
if (m * (m + 1) / 2 < n)
l = m + 1, w = m;
else
r = m - 1;
}
l = w;
x = l * (l + 1) / 2 + l * (l - 1) / 2 + 1;
n = n - (l * (l + 1)) / 2;
cout << x + n + n - 2;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |