CF2253A.The Best Card
入门
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In a card game, there are n cards with values 2,3,4,…,n+1.
To determine which of two cards with values x and y wins, apply the following rules:
- if one of the numbers x and y is divisible by the other, the card with the smaller value wins;
- otherwise, the card with the larger value wins.
For example, between cards 2 and 6, card 2 wins because 6 is divisible by 2. Between cards 4 and 6, card 6 wins because neither of these numbers is divisible by the other.
Determine whether there exists a card that wins against every other card.
在一种纸牌游戏中,有 n 张牌,其牌面值分别为 2,3,4,…,n+1。
为判断两张牌面值分别为 x 和 y 的牌中哪张获胜,按以下规则判定:
- 若 x 与 y 中有一个数能被另一个整除,则牌面值较小的牌获胜;
- 否则,牌面值较大的牌获胜。
例如,在牌面值为 2 和 6 的两张牌之间,2 获胜,因为 6 能被 2 整除;在牌面值为 4 和 6 的两张牌之间,6 获胜,因为这两个数互不整除。
试判断是否存在一张牌,它能战胜其余所有牌。
输入格式
The first line contains an integer t (1≤t≤104) — the number of test cases.
The only line of each test case contains an integer n (2≤n≤2⋅105) — the number of cards in the game.
Additional constraints on the input:
- the sum of n over all test cases does not exceed 3⋅106.
第一行包含一个整数 t(1≤t≤104)——测试用例的数量。
每个测试用例仅一行,包含一个整数 n(2≤n≤2⋅105)——游戏中卡片的数量。
输入的额外约束:
- 所有测试用例的 n 之和不超过 3⋅106。
输出格式
For each test case, print YES if there is a card that wins against all other cards, and NO otherwise.
Each letter may be printed in either case. For example, YES, yes, and yEs are all recognized as a positive answer.
对于每个测试用例,如果存在一张牌能击败所有其他牌,则输出 YES;否则输出 NO。
每个字母可使用大写或小写形式。例如,YES、yes 和 yEs 均被视为肯定回答。
输入输出样例
输入#1
5 2 3 4 5 8
输出#1
YES NO YES NO NO
说明/提示
In the first test case, the available cards have values 2 and 3. Card 3 wins against card 2.
In the second test case, the available cards have values 2, 3, and 4. Card 2 wins against card 4, card 3 wins against card 2, and card 4 wins against card 3, so there is no suitable card.
在第一个测试用例中,可用的卡片数值为 2 和 3。卡片 3 战胜卡片 2。
在第二个测试用例中,可用的卡片数值为 2、3 和 4。卡片 2 战胜卡片 4,卡片 3 战胜卡片 2,卡片 4 战胜卡片 3,因此不存在合适的卡片。
输入解题思路,AI测评打分。不知道怎么写?