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;
}