Submission #1112861

#TimeUsernameProblemLanguageResultExecution timeMemory
1112861Pishka12Odd-even (IZhO11_oddeven)C++14
0 / 100
1 ms336 KiB
#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 timeMemoryGrader output
Fetching results...