欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1615B.And It's Non-Zero
And It's Non-Zero
CF1615B · And It's Non-Zero
- 难度:1300
- 标签:bitmasks、greedy、math
- 链接:https://codeforces.com/problemset/problem/1615/B
- 时间限制:2 seconds 内存限制:256 megabytes
- 出现位置:Day22-阶段模拟4-S T1-T3综合卷
英文原题面
Statement
You are given an array consisting of all integers from inclusive. For example, if and , the array would be . What's the minimum number of elements you can delete to make the bitwise AND of the array non-zero? A bitwise AND is a binary operation that takes two equal-length binary representations and performs the AND operation on each pair of the corresponding bits.
Input
The first line contains one integer () — the number of test cases. Then cases follow. The first line of each test case contains two integers and () — the description of the array.
Output
For each test case, output a single integer — the answer to the problem.
样例
样例 1
输入:
5
1 2
2 8
4 5
1 5
100000 200000
输出:
1
3
0
2
31072
样例解释(英文原文)
In the first test case, the array is . Currently, the bitwise AND is , as . However, after deleting (or ), the array becomes (or ), and the bitwise AND becomes (or ). This can be proven to be the optimal, so the answer is . In the second test case, the array is . Currently, the bitwise AND is . However, after deleting , , and , the array becomes , and the bitwise AND becomes . This can be proven to be the optimal, so the answer is . Note that there may be other ways to delete elements.
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |