欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1688B.Patchouli's Magical Talisman
Patchouli's Magical Talisman
She is skilled in all kinds of magics, and is keen on inventing new one.—Perfect Memento in Strict Sense
Patchouli is making a magical talisman. She initially has magical tokens. Their magical power can be represented with positive integers .
Patchouli may perform the following two operations on the tokens.
- Fusion: Patchouli chooses two tokens, removes them, and creates a new token with magical power equal to the sum of the two chosen tokens.
- Reduction: Patchouli chooses a token with an even value of magical power , removes it and creates a new token with magical power equal to .
Tokens are more effective when their magical powers are odd values. Please help Patchouli to find the minimum number of operations she needs to make magical powers of all tokens odd values.
Input
Each test contains multiple test cases.
The first line contains a single integer () — the number of test cases. The description of the test cases follows.
For each test case, the first line contains one integer () — the initial number of tokens.
The second line contains intergers () — the initial magical power of the tokens.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print a single integer — the minimum number of operations Patchouli needs to make all tokens have an odd value of magical power.
It can be shown that under such restrictions the required sequence of operations exists.
Note
Test case 1:
consists solely of odd numbers initially.
Test case 2:
Choose the tokens with magical power of and and perform Fusion. Now , both are odd numbers.
Test case 3:
Choose the tokens with magical power of and and perform Fusion. Now .
Choose the token with magical power of and perform Reduction. Now .
Choose the tokens with magical power of and and perform Fusion. Now , and is an odd number.
It can be shown that you can not make all the magical powers odd numbers in less than moves, so the answer is .
Samples
4
2
1 9
3
1 1 2
3
2 4 8
3
1049600 33792 1280
0
1
3
10
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |