# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1045622 | 2024-08-06T06:31:27 Z | ezzzay | 홀-짝 수열 (IZhO11_oddeven) | C++14 | 0 ms | 348 KB |
#include <bits/stdc++.h> #define pb push_back #define endl "\n" #define mp make_pair #define fi first #define se second #define all(x) x.begin(), x.end() #define fname "" #define sz(x) (int)(x.size()) typedef long long ll; using namespace std; const ll N = (ll)(5e5) + 322; const ll INF = (ll)(2e9); const ll mod = (ll)(1e9) + 7; const double eps = 1e-9; ll n, l = 0, r = INF, ans; ll calc(ll x) {return (x) * (x + 1) / 2ll;} int main () { ios_base :: sync_with_stdio (false); cin.tie(0); //freopen(fname".in", "r", stdin); //freopen(fname".out", "w", stdout); scanf("%lld", &n); while (r - l > 1) { ll mid = (r + l) / 2ll; if (calc(mid) >= n) r = mid; else l = mid; } ans = n + (n - l - 1); printf("%lld", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Incorrect | 0 ms | 348 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |