# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
379765 | SolarSystem | Odd-even (IZhO11_oddeven) | C++17 | 1 ms | 512 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;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin >> n;
long long l = 0, r = 1e18;
while (l + 1 < r) {
long long m = (l + r) / 2;
if ((long double) m > (long double) 2e18 / (m + 1) || m * (m + 1) / 2 > n) {
r = m;
} else {
l = m;
}
}
if (l * (l + 1) / 2 == n) cout << l * l;
else {
cout << l * l + (n - l * (l + 1) / 2) * 2 - 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |