A. Magical Sticks

http://www.yyycode.cn/index.php/2020/07/02/a-magical-sticks/


A penguin Rocher has nn sticks. He has exactly one stick with length ii for all 1≤i≤n1≤i≤n.

He can connect some sticks. If he connects two sticks that have lengths aa and bb, he gets one stick with length a+ba+b. Two sticks, that were used in the operation disappear from his set and the new connected stick appears in his set and can be used for the next connections.

He wants to create the maximum number of sticks that have the same length. It is not necessary to make all sticks have the same length, some sticks can have the other length. How many sticks with the equal length he can create?

Input

The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤10001≤t≤1000) — the number of test cases. Next tt lines contain descriptions of test cases.

For each test case, the only line contains a single integer nn (1≤n≤1091≤n≤109).

Output

For each test case, print a single integer  — the answer to the problem.

Example

input

Copy

4
1
2
3
4

output

Copy

1
1
2
2

Note

In the third case, he can connect two sticks with lengths 11 and 22 and he will get one stick with length 33. So, he will have two sticks with lengths 33.

In the fourth case, he can connect two sticks with lengths 11 and 33 and he will get one stick with length 44. After that, he will have three sticks with lengths {2,4,4}{2,4,4}, so two sticks have the same length, and one stick has the other length.


題意:給一個n,代表有1-n的長度的小木棍。問任意無限拼接兩個木棍,問最後最多能有幾根長度一樣的木棍

思路:有點等差數列的味道,在n爲偶數的時候,a1+an=a2+an-1=a3+an-2=……剛好爲n/2,當n爲奇數的時候,不用管最後一個數,奇數-1=偶數,那麼前面的最多爲n/2個,且前面加起來的每個合成木棍和最後一個數的合成木棍長度是一樣的,所以爲n/2+1;

比如n=7, 1 2 3 4 5 6 7;1+6=7;2+5=7;3+4=7;7=7;

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5;
typedef long long LL;

int main(void)
{
	LL t;cin>>t;
	while(t--)
	{
		LL n;cin>>n;
		cout<<(1+n)/2<<endl;
	}

return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章