Logo
(追記) (追記ここまで)

31129번 - Balls 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB92250.000%

문제

Alice and Bob are playing a game. They've got $B$ blue and $R$ red balls laid out before them. Alice has the first move, and after that, players alternate moves. Alice picks a random ball and removes it. Bob removes a single red ball.

Alice chooses her balls randomly with equal probability regardless of their color. It does not matter which red ball Bob removes.

The game ends when one of the two outcomes occurs:

  • there are no more blue balls --- Alice wins;
  • there are strictly more blue balls than there are red balls --- Bob wins.

Alice and Bob would like a balance of outcomes, and are curious as for what number of blue balls is necessary for a game of $C = B + R$ for the probability of Alice winning to be as close to 50ドル\%$ as possible. In other words, they want to minimize the value $\left| h - 0.5 \right|$.

입력

The first line of the input file contains a single integer $G$ --- the number of games Alice and Bob plan to play (1ドル \le G \le 10^5$).

The following lines define the number of balls $C$ in each game(2ドル \le C \le 2 \cdot 10^5$), one line per game.

출력

For each game, print the number of blue balls necessary for the chance of Alice's victory to be as close as possible to 50ドル\%$ in a separate line in the same order as in the input file.

제한

예제 입력 1

5
2
3
6
7
8

예제 출력 1

1
1
2
1
2

힌트

출처

Contest > Open Cup > 2021/2022 Season > Stage 5: Grand Prix of Siberia 7번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /