A15439 | Tea with Tangerines
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ pieces of tangerine peel, the $i$ -th of them has size $a_i$ . In one step it is possible to divide one piece of size $x$ into two pieces of positive integer sizes $y$ and $z$ so that $y + z = x$ .
You want that for each pair of pieces, their sizes differ strictly less than twice. In other words, there should not be two pieces of size $x$ and $y$ , such that $2x \le y$ . What is the minimum possible number of steps needed to satisfy the condition?
You want that for each pair of pieces, their sizes differ strictly less than twice. In other words, there should not be two pieces of size $x$ and $y$ , such that $2x \le y$ . What is the minimum possible number of steps needed to satisfy the condition?
输入格式
The first line of the input contains a single integer $t$ ( $1 \le t \le 100$ ) — the number of test cases. The description of test cases follows.
The first line of each test case contains the integer $n$ ( $1 \le n \le 100$ ).
Then one line follows, containing $n$ integers $a_1 \le a_2 \le \ldots \le a_n$ ( $1 \le a_i \le 10^7$ ).
The first line of each test case contains the integer $n$ ( $1 \le n \le 100$ ).
Then one line follows, containing $n$ integers $a_1 \le a_2 \le \ldots \le a_n$ ( $1 \le a_i \le 10^7$ ).
输出格式
For each test case, output a single line containing the minimum number of steps.
输入输出样例
输入 #1
3 5 1 2 3 4 5 1 1033 5 600 900 1300 2000 2550
输出 #1
10 0 4
In the first test case, we initially have a piece of size $1$ , so all final pieces must have size $1$ . The total number of steps is: $0 + 1 + 2 + 3 + 4 = 10$ .
In the second test case, we have just one piece, so we don't need to do anything, and the answer is $0$ steps.
In the third test case, one of the possible cut options is: $600,\ 900,\ (600 | 700),\ (1000 | 1000),\ (1000 | 1000 | 550)$ . You can see this option in the picture below. The maximum piece has size $1000$ , and it is less than $2$ times bigger than the minimum piece of size $550$ . $4$ steps are done. We can show that it is the minimum possible number of steps.

In the second test case, we have just one piece, so we don't need to do anything, and the answer is $0$ steps.
In the third test case, one of the possible cut options is: $600,\ 900,\ (600 | 700),\ (1000 | 1000),\ (1000 | 1000 | 550)$ . You can see this option in the picture below. The maximum piece has size $1000$ , and it is less than $2$ times bigger than the minimum piece of size $550$ . $4$ steps are done. We can show that it is the minimum possible number of steps.

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted