Submission #879600

#TimeUsernameProblemLanguageResultExecution timeMemory
879600Elvin_FritlOdd-even (IZhO11_oddeven)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define io                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
 
 
typedef long long ll;
 
ll bp(ll n,ll m){
    if(m == 0){
        return 1;
    }
    if(m == 1){
        return n;
    }
    if(m%2==0){
        return bp(n*n,m/2);
    }
    return n*bp(n,m-1);
}
 
 
const int N =  1e6 + 545, M = 33, inf = 1e9 + 99;
const ll inff = 1e12;

 
int main() {
	ll n;
	cin >> n;
    ll l = 1 , r = 1e9;
    while (l < r) {
        ll mid = (l + r) >> 1;
        if(mid * (mid + 1) / 2LL >= n) {
			r = mid;
		}
        else {
			l = mid + 1;
		}
    }
    cout << (n - l) * 2 + l;
    
}
#Verdict Execution timeMemoryGrader output
Fetching results...