#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define meta int tm = (tl + tr) / 2, x = i * 2 + 1, y = x + 1
const int N = 2e5 + 7;
const int oo = 1e9;
const int mod = 1e9 + 7;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int a, l, r = oo;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> a;
if (a > oo) {
while (1) {
l++;
}
}
while (l < r) {
int m = (l + r) / 2;
if (m * (m + 1) / 2 < a) l = m + 1;
else r = m;
} r--;
cout << a * 2 - r - 1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |