欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1735B.Tea with Tangerines
Tea with Tangerines
There are pieces of tangerine peel, the -th of them has size . In one step it is possible to divide one piece of size into two pieces of positive integer sizes and so that .
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 and , such that . What is the minimum possible number of steps needed to satisfy the condition?
Input
The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains the integer ().
Then one line follows, containing integers ().
Output
For each test case, output a single line containing the minimum number of steps.
Note
In the first test case, we initially have a piece of size , so all final pieces must have size . The total number of steps is: .
In the second test case, we have just one piece, so we don't need to do anything, and the answer is 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 , and it is less than times bigger than the minimum piece of size . steps are done. We can show that it is the minimum possible number of steps.

Samples
3
5
1 2 3 4 5
1
1033
5
600 900 1300 2000 2550
10
0
4
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |