1.题目:

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 t (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 n (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.

2.题解:

举例,进行分析:

总而言之 ,当n为奇数时:y=(n+1)/2;

当n为偶数时:y=n/2=(n+1)/2;  //这样的话,无论n的奇偶性,y均可用y=(n+1)/2;表示,从而简化了代码。

3:AC代码:

#include<iostream>
using namespace std;
int main()
{int n,t,y;cin>>t;for(int m=1;m<=t;m++){cin>>n;y=(n+1)/2;cout<<y<<endl;}return 0;} 

Magical Sticks相关推荐

  1. codeforces654题解_[codeforces 1374A] Magical Sticks 棍子拼接

    Codeforces Round #654 (Div. 2)   参与排名人数14349   本场比赛主要心思放在观摩高手如何打比赛,发现初中生真的很厉害. [codeforces 1374A]    ...

  2. Magical Sticks 棍子拼接

    Magical Sticks 棍子拼接 A penguin Rocher has n sticks. He has exactly one stick with length i for all 1≤ ...

  3. A. Magical Sticks

    http://www.yyycode.cn/index.php/2020/07/02/a-magical-sticks/ A penguin Rocher has nn sticks. He has ...

  4. CF1371A Magical Sticks

    题面传送门 显然是可以分类讨论的. 如果nnn是奇数,那么我们可以让111与n−1n-1n−1,222与n−2n-2n−2组成一对,剩下nnn一对,这样可以组成n+12\frac{n+1}{2}2n+ ...

  5. kuangbin带你飞专题合集

    题目列表 [kuangbin带你飞]专题一 简单搜索 [kuangbin带你飞]专题二 搜索进阶 [kuangbin带你飞]专题三 Dancing Links [kuangbin带你飞]专题四 最短路 ...

  6. 算法学习经典例题整理

    陆续会对本篇博客进行更新! 搜索:https://vjudge.net/contest/292597 区间DP:https://vjudge.net/contest/293892 树状背包:https ...

  7. Codeforces Round #654 (Div. 2)

    A.Magical Sticks 贪心凑长度为nnn的木棒 #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include& ...

  8. ACM概率期望dp刷题总结

    这个周刷了很多概率期望有关的dp题目,缘起2016青岛D题和取log的神操作题HDU 5988 2016青岛区域赛 (最小费用流) 这类题目没有固定的模板,而且概率可以很容易插入一些经典模型,比如下面 ...

  9. kuangbin带你飞 专题1-23 题单

    kuangbin大神,对于打过ACM比赛的ACMer,无人不知无人不晓. 在此,附上vjudge平台上一位大神整理的[kuangbin带你飞]专题目录链接. [kuangbin带你飞专题目录1-23] ...

最新文章

  1. 伯明翰大学计算机科学网络安全硕士,2020年伯明翰大学网络安全硕士专业硕士申请条件-学费-世界排名...
  2. golang 关于golang.org/x包问题
  3. Haddop学习:(一)序
  4. CAN总线基础(三)
  5. 【Ray Tracing in One Weekend 超详解】 光线追踪1-7 Dielectric 半径为负,实心球体镂空技巧...
  6. 电路宽度测量halcon例子
  7. JAVA day08 接口(interface),多态,instanceof
  8. 推荐微软Windows 8 Metro应用开发虚拟实验室
  9. 一个比较好的多人网络游戏菜单程序。
  10. android developer tools下载地址
  11. The conda.compat module is deprecated and will be removed in a future releas错误记录
  12. android 按键 设置在哪,如何在Android设备上设置按键和按键?
  13. STC51单片机16——将输入信号2倍频
  14. 1237 -- 地盘划分
  15. 【Android】获取当前的安卓版本号的代码
  16. 零经验小白的独游历程——U3d学习经验与教程分享
  17. pytorch快速上手-使用自动标注软件Openlabeling和yolov5快速完成目标检测
  18. 作业指导书分析怎么做?制作作业指导书分析的软件有哪些?
  19. 如何完成一次 git pr
  20. bim综合软件:一次性快速解锁所有轴网,生成轴网

热门文章

  1. 愤怒的小鸟角色模型案例,3DMAX快速建模游戏模型一些不为人知的秘诀!
  2. Linux服务器之间设置共享目录
  3. Spring IO 平台参考指南
  4. 【无标题】使用阿里云短信服务发送短信
  5. filecoin lotus deal(交易)状态及 sectors(扇区)状态
  6. python数据科学常国珍_python数据科学:技术详解与商业实践
  7. 米2s 进入recovery模式
  8. mysql 数据库设计说明书_1.2 Mysql 数据库规范
  9. 部标JT808的指令构造详解及示例
  10. 我的家庭私有云计划-17