欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1789A.Serval and Mocha's Array
Serval and Mocha's Array
Mocha likes arrays, and Serval gave her an array consisting of positive integers as a gift.
Mocha thinks that for an array of positive integers , it is good iff the greatest common divisor of all the elements in is no more than its length. And for an array of at least positive integers, it is beautiful iff all of its prefixes whose length is no less than are good.
For example:
- is not good, because is greater than its length .
- is both good and beautiful, because all of its prefixes whose length is no less than , which are and , are both good.
- is good but not beautiful, because is not good.
Now Mocha gives you the gift array of positive integers, and she wants to know whether array could become beautiful by reordering the elements in . It is allowed to keep the array unchanged.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the length of array .
The second line of each test case contains integers () — the elements of array .
Output
For each test case, print Yes if it is possible to reorder the elements in to make it beautiful, and print No if not.
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
In the first test case, neither nor are beautiful, so it's impossible to obtain a beautiful array by reordering the elements in .
In the second test case, is already beautiful. Keeping the array unchanged can obtain a beautiful array.
Samples
6
2
3 6
3
1 2 4
3
3 6 1
3
15 35 21
4
35 10 35 14
5
1261 227821 143 4171 1941
No
Yes
Yes
No
Yes
Yes
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |