Submission #859973

# Submission time Handle Problem Language Result Execution time Memory
859973 2023-10-11T09:02:31 Z aykhn Odd-even (IZhO11_oddeven) C++14
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
// author : aykhn
 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
 
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define int ll
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
__int128 read() {
    __int128 x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
void print(__int128 x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}
 
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    __int128 n;
    n = read();
  	__int128 lim = 1e18;
  	assert(n <= lim);
    __int128 l = 1; 
    __int128 r = 1e9;
    while (l < r)
    {
        __int128 mid = (l + r) >> 1;
        if (mid * (mid + 1) / 2 >= n) r = mid;
        else l = mid + 1;
    }
    __int128 x = l - 1;
    __int128 y = n - 1;
    print((y - x) * 2 + x + 1);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Runtime error 1 ms 604 KB Execution killed with signal 6
14 Halted 0 ms 0 KB -