CF1862D.Ice Cream Balls
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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,…. 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=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.
特马决定提升自己的冰淇淋制作技艺。他已学会如何用恰好两个球制作锥形冰淇淋。
在沉迷冰淇淋之前,特马对数学颇感兴趣。因此,他很好奇:为了恰好能制作出 n 种不同的冰淇淋,他至少需要准备多少个冰淇淋球?
可选的冰淇淋口味有无数种:1,2,3,…。特马可以用任意两种口味(甚至相同口味)来制作双球冰淇淋。
若两种冰淇淋的球口味集合不同,则视为不同类型。例如,{1,2}={2,1},但 {1,1}={1,2}。
例如,若特马手头的冰淇淋球为 {1,1,2},则他仅能制作出两种冰淇淋:{1,1} 和 {1,2}。
注意:特马无需同时制作所有冰淇淋甜筒;也就是说,他可以独立地、逐个制作每一份甜筒。此外,若要制作一份口味组合为 {x,x} 的甜筒(其中 x 为某一口味),特马手中至少需有 2 个口味为 x 的球。
请帮助特马回答这个问题。可以证明:该问题的答案恒存在。
输入格式
Each test consists of multiple test cases. The first line of input contains a single integer t (1≤t≤104) — 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≤n≤1018) — the number of ice cream types that Tema wants to make.
每个测试包含多个测试用例。输入的第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤1018),表示 Tema 想要制作的冰淇淋种类数量。
输出格式
For each test case, output a single integer — the minimum number of balls Tema needs to buy.
对于每个测试用例,输出一个整数——Tema 需要购买的球的最小数量。
输入输出样例
输入#1
5 1 3 6 179 1000000000000000000
输出#1
2 3 4 27 2648956421
说明/提示
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.
在第一个样例中,只需以下种类的球:1,1。注意,集合 1 并不足够,因为我们至少需要 2 个类型为 1 的球,才能构成这样的圆锥 1,1。
在第二个样例中,无法仅用 2 个球完成,但使用这些球 1,2,3 即可实现。
在第三个样例中,1,2,3,4 是最优答案,因此我们可以得到如下冰淇淋圆锥:1,2、1,3、1,4、2,3、2,4、3,4。
输入解题思路,AI测评打分。不知道怎么写?