CF1810H.Last Number

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a multiset SS . Initially, S={1,2,3,,n}S = \{1,2,3, \ldots, n\} .

You will perform the following operation n1n-1 times.

  • Choose the largest number SmaxS_{\text{max}} in SS and the smallest number SminS_{\text{min}} in SS . Remove the two numbers from SS , and add SmaxSminS_{\text{max}} - S_{\text{min}} into SS .

It's easy to show that there will be exactly one number left after n1n-1 operations. Output that number.

输入格式

Each test contains multiple test cases. The first line contains a single integer tt ( 1t1051 \le t \le 10^5 ) — the number of test cases. Their description follows.

For each test case, one single line contains a single integer nn ( 2n1092 \le n \le 10^9 ) — the initial size of the multiset SS .

输出格式

For each test case, output an integer denoting the only number left after n1n-1 operations.

输入输出样例

  • 输入#1

    5
    2
    4
    7
    15
    177567

    输出#1

    1
    2
    2
    4
    33914

说明/提示

We show how the multiset SS changes for n=4n=4 .

  • Operation 11 : S={1,2,3,4}S=\{1,2,3,4\} , remove 44 , 11 , add 33 .
  • Operation 22 : S={2,3,3}S=\{2,3,3\} , remove 33 , 22 , add 11 .
  • Operation 33 : S={1,3}S=\{1,3\} , remove 33 , 11 , add 22 .
  • Final: S={2}S = \{2\} .

Thus, the answer for n=4n = 4 is 22 .

首页