310628: CF1862D. Ice Cream Balls

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Ice Cream Ballstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Tema decided to improve his ice cream making skills. He has already learned how to make ice cream in a cone using exactly two balls.

Before his ice cream obsession, Tema was interested in mathematics. Therefore, he is curious about the minimum number of balls he needs to have in order to make exactly $n$ different types of ice cream.

There are plenty possible ice cream flavours: $1, 2, 3, \dots$. Tema can make two-balls ice cream with any flavours (probably the same).

Two ice creams are considered different if their sets of ball flavours are different. For example, $\{1, 2\} = \{2, 1\}$, but $\{1, 1\} \neq \{1, 2\}$.

For example, having the following ice cream balls: $\{1, 1, 2\}$, Tema can make only two types of ice cream: $\{1, 1\}$ and $\{1, 2\}$.

Note, that Tema do not need to make all the ice cream cones at the same time. This means that he making ice cream cones independently. Also in order to make a following cone $\{x, x\}$ for some $x$, Tema needs at least $2$ balls of type $x$.

Help Tema answer this question. It can be shown that answer always exist.

Input

Each test consists of multiple test cases. The first line of input contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Then follows the description of the test cases.

The first line of each test case contains a single integer $n$ ($1 \le n \le 10^{18}$) — the number of ice cream types that Tema wants to make.

Output

For each test case, output a single integer — the minimum number of balls Tema needs to buy.

ExampleInput
5
1
3
6
179
1000000000000000000
Output
2
3
4
27
2648956421
Note

In the first sample, it is enough to have following balls types: $\{1, 1\}$. Note, that set $\{1\}$ if not enough since we need at least $2$ balls of a type $1$ in order to make such cone $\{1, 1\}$.

In the second sample, it is not possible to make it with $2$ balls, but it can be done with these balls: $\{1, 2, 3\}$.

In the third sample, $\{1, 2, 3, 4\}$ is optimal answer, so we can get following ice cream cones: $\{1, 2\}$, $\{1, 3\}$, $\{1, 4\}$, $\{2, 3\}$, $\{2, 4\}$, $\{3, 4\}$.

Output

题目大意:
Tema想要提高他制作冰淇淋的技能。他已经学会了如何用恰好两个球制作冰淇淋蛋筒。在Tema对冰淇淋的痴迷之前,他对数学很感兴趣。因此,他很好奇他需要至少有多少个球才能制作出恰好n种不同的冰淇淋。有多种可能的冰淇淋口味:1, 2, 3, ...。Tema可以用任何口味的两个球制作冰淇淋(可能是相同的口味)。如果两个冰淇淋的球口味集合不同,则认为它们是不同的。例如,{1, 2} = {2, 1},但 {1, 1} ≠ {1, 2}。例如,如果有以下冰淇淋球:{1, 1, 2},Tema只能制作两种类型的冰淇淋:{1, 1} 和 {1, 2}。注意,Tema不需要同时制作所有的冰淇淋蛋筒。这意味着他独立制作冰淇淋蛋筒。为了制作接下来的蛋筒{ x, x }对于某个x,Tema需要至少2个类型为x的球。帮助Tema回答这个问题。可以证明答案总是存在的。

输入输出数据格式:
输入:
每个测试包含多个测试用例。输入的第一行包含一个整数t(1 ≤ t ≤ 10^4)——测试用例的数量。然后是测试用例的描述。
每个测试用例的第一行包含一个整数n(1 ≤ n ≤ 10^18)——Tema想要制作的冰淇淋类型的数量。

输出:
对于每个测试用例,输出一个整数——Tema需要购买的球的最小数量。

示例:
输入:
5
1
3
6
179
1000000000000000000

输出:
2
3
4
27
2648956421题目大意: Tema想要提高他制作冰淇淋的技能。他已经学会了如何用恰好两个球制作冰淇淋蛋筒。在Tema对冰淇淋的痴迷之前,他对数学很感兴趣。因此,他很好奇他需要至少有多少个球才能制作出恰好n种不同的冰淇淋。有多种可能的冰淇淋口味:1, 2, 3, ...。Tema可以用任何口味的两个球制作冰淇淋(可能是相同的口味)。如果两个冰淇淋的球口味集合不同,则认为它们是不同的。例如,{1, 2} = {2, 1},但 {1, 1} ≠ {1, 2}。例如,如果有以下冰淇淋球:{1, 1, 2},Tema只能制作两种类型的冰淇淋:{1, 1} 和 {1, 2}。注意,Tema不需要同时制作所有的冰淇淋蛋筒。这意味着他独立制作冰淇淋蛋筒。为了制作接下来的蛋筒{ x, x }对于某个x,Tema需要至少2个类型为x的球。帮助Tema回答这个问题。可以证明答案总是存在的。 输入输出数据格式: 输入: 每个测试包含多个测试用例。输入的第一行包含一个整数t(1 ≤ t ≤ 10^4)——测试用例的数量。然后是测试用例的描述。 每个测试用例的第一行包含一个整数n(1 ≤ n ≤ 10^18)——Tema想要制作的冰淇淋类型的数量。 输出: 对于每个测试用例,输出一个整数——Tema需要购买的球的最小数量。 示例: 输入: 5 1 3 6 179 1000000000000000000 输出: 2 3 4 27 2648956421

加入题单

上一题 下一题 算法标签: