#include <bits/stdc++.h>
using namespace std;
unsigned long long n, l = 0, r = 1e18 + 1, x, w;
int main ()
{
#ifdef Elibay
freopen (".in", "r", stdin);
#endif
cin >> n;
while (l <= r)
{
unsigned long long m = (l + r) >> 1;
if (m * (m + 1) / 2 < n)
l = m + 1, w = m;
else
r = m - 1;
}
l = w;
x = l * (l + 1) / 2 + l * (l - 1) / 2 + 1;
n = n - (l * (l + 1)) / 2;
cout << x + n + n - 2;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1716 KB |
Output is correct |
2 |
Correct |
0 ms |
1716 KB |
Output is correct |
3 |
Correct |
0 ms |
1716 KB |
Output is correct |
4 |
Correct |
0 ms |
1716 KB |
Output is correct |
5 |
Correct |
0 ms |
1716 KB |
Output is correct |
6 |
Correct |
0 ms |
1716 KB |
Output is correct |
7 |
Correct |
0 ms |
1716 KB |
Output is correct |
8 |
Correct |
0 ms |
1716 KB |
Output is correct |
9 |
Correct |
0 ms |
1716 KB |
Output is correct |
10 |
Correct |
0 ms |
1716 KB |
Output is correct |
11 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
17 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
20 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
21 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
22 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |