CF1371A.Magical Sticks

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

A penguin Rocher has nn sticks. He has exactly one stick with length ii for all 1≤i≤n1 \le i \le 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?

企鹅罗彻有 nn 根木棍。对于所有满足 1≤i≤n1 \le i \le n 的整数 ii,他恰好有一根长度为 ii 的木棍。

他可以将若干根木棍连接起来。若他将两根长度分别为 aa 和 bb 的木棍连接起来,则得到一根长度为 a+ba + b 的新木棍。参与此次操作的两根木棍会从他的集合中消失,而新生成的这根连接后的木棍则加入集合,并可用于后续的连接操作。

他希望构造出尽可能多的、长度完全相同的木棍。不要求所有木棍最终长度都相同,允许部分木棍具有其他长度。那么,他最多能构造出多少根长度相等的木棍?

输入格式

The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤10001 \le t \le 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 \le n \le 10^{9}).

输入包含多个测试用例。第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000),表示测试用例的数量。接下来的 tt 行分别描述各测试用例。

对于每个测试用例,唯一的一行包含一个整数 nn(1≤n≤1091 \le n \le 10^{9})。

输出格式

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

对于每个测试用例,输出一个整数——即该问题的答案。

输入输出样例

  • 输入#1

    4
    1
    2
    3
    4

    输出#1

    1
    1
    2
    2

说明/提示

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.

在第三种情况下,他可以连接两根长度分别为 11 和 22 的木棍,从而得到一根长度为 33 的木棍。因此,他将拥有两根长度均为 33 的木棍。

在第四种情况下,他可以连接两根长度分别为 11 和 33 的木棍,从而得到一根长度为 44 的木棍。之后,他将拥有三根长度分别为 2,4,4{2, 4, 4} 的木棍,即其中两根长度相同,另一根长度不同。

输入解题思路,AI测评打分。不知道怎么写?

首页