# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1112861 | Pishka12 | Odd-even (IZhO11_oddeven) | C++14 | 1 ms | 336 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 ll long long
#define f first
#define s second
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll n;
cin>>n;
n--;
ll l = 0,r = 1e9,le = 0;
while(l<=r) {
ll m = (l+r)/2;
if (m*(m+1)/2 + m > n) {
r= m-1;
}
else {
l = m+1;
le = m;
}
}
ll ans = 1;
ans += le*(le+1) + le;
n -= le*(le+1)/2 + le;
if (n >= 1) {
ans++;
n--;
ans+= n*2;
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |