Submission #17846

#TimeUsernameProblemLanguageResultExecution timeMemory
17846ElibayOdd-even (IZhO11_oddeven)C++14
45.45 / 100
0 ms1716 KiB
#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 timeMemoryGrader output
Fetching results...