欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1624C.Division by Two and Permutation
Division by Two and Permutation
You are given an array consisting of positive integers. You can perform operations on it.
In one operation you can replace any element of the array with , that is, by an integer part of dividing by (rounding down).
See if you can apply the operation some number of times (possible ) to make the array become a permutation of numbers from to —that is, so that it contains all numbers from to , each exactly once.
For example, if , , then the answer is yes. You could do the following:
- Replace with , then .
- Replace with , then .
- Replace with , then .
- Replace with , then .
Input
The first line of input data contains an integer () —the number of test cases.
Each test case contains exactly two lines. The first one contains an integer (), the second one contains integers ().
Output
For each test case, output on a separate line:
YESif you can make the array become a permutation of numbers from to ,NOotherwise.
You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).
Note
The first test case is explained in the text of the problem statement.
In the second test case, it is not possible to get a permutation.
Samples
6
4
1 8 25 2
2
1 1
9
9 8 3 4 2 7 1 5 6
3
8 2 1
4
24 7 16 7
5
22 6 22 4 22
YES
NO
YES
NO
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |