답안 #17858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17858 2016-01-12T14:20:22 Z Adilkhan 홀-짝 수열 (IZhO11_oddeven) C++
54.55 / 100
0 ms 1720 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1720 KB Output is correct
2 Correct 0 ms 1720 KB Output is correct
3 Correct 0 ms 1720 KB Output is correct
4 Correct 0 ms 1720 KB Output is correct
5 Correct 0 ms 1720 KB Output is correct
6 Correct 0 ms 1720 KB Output is correct
7 Correct 0 ms 1720 KB Output is correct
8 Correct 0 ms 1720 KB Output is correct
9 Correct 0 ms 1720 KB Output is correct
10 Correct 0 ms 1720 KB Output is correct
11 Correct 0 ms 1720 KB Output is correct
12 Correct 0 ms 1720 KB Output is correct
13 Incorrect 0 ms 1720 KB Output isn't correct
14 Incorrect 0 ms 1720 KB Output isn't correct
15 Incorrect 0 ms 1720 KB Output isn't correct
16 Incorrect 0 ms 1720 KB Output isn't correct
17 Incorrect 0 ms 1720 KB Output isn't correct
18 Incorrect 0 ms 1720 KB Output isn't correct
19 Incorrect 0 ms 1720 KB Output isn't correct
20 Incorrect 0 ms 1720 KB Output isn't correct
21 Incorrect 0 ms 1720 KB Output isn't correct
22 Incorrect 0 ms 1720 KB Output isn't correct