A16094 | Ice Cream Balls
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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.
输出格式
For each test case, output a single integer — the minimum number of balls Tema needs to buy.
输入输出样例
输入 #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\}$ .
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\}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted