# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
524615 | lukameladze | Odd-even (IZhO11_oddeven) | C++14 | 1 ms | 332 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>
#define f first
#define s second
#define pb push_back
#define int long long
using namespace std;
const int N = 3e5 + 5;
int raod,cur,n,le,ri,ans,lef,rem;
main() {
cin>>n;
le = 0;
ri = 1e10;
while (le <= ri) {
int mid = (le + ri) / 2;
if ((mid*(mid + 1))/2 < n) {
ans = mid;
le = mid + 1;
} else ri = mid - 1;
}
lef = ans*ans+1;
rem = n - (ans*(ans + 1))/2;
cout<<lef + (rem - 1)*2<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |