CF1603A.Di-visible Confusion
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
YouKn0wWho has an integer sequence a1,a2,…,an. He will perform the following operation until the sequence becomes empty: select an index i such that 1≤i≤∣a∣ and ai is not divisible by (i+1), and erase this element from the sequence. Here ∣a∣ is the length of sequence a at the moment of operation. Note that the sequence a changes and the next operation is performed on this changed sequence.
For example, if a=[3,5,4,5], then he can select i=2, because a2=5 is not divisible by i+1=3. After this operation the sequence is [3,4,5].
Help YouKn0wWho determine if it is possible to erase the whole sequence using the aforementioned operation.
YouKn0wWho 有一个整数序列 a1,a2,…,an。他将重复执行以下操作,直到序列变为空:选择一个下标 i,满足 1≤i≤∣a∣,且 ai 不能被 (i+1) 整除,并将该元素从序列中删除。其中 ∣a∣ 表示当前操作时序列 a 的长度。注意,序列 a 会随之改变,后续操作均在更新后的序列上进行。
例如,若 a=[3,5,4,5],则他可以选择 i=2,因为 a2=5 不能被 i+1=3 整除。执行该操作后,序列变为 [3,4,5]。
请帮助 YouKn0wWho 判断:能否通过上述操作将整个序列全部删除。
输入格式
The first line contains a single integer t (1≤t≤10000) — the number of test cases.
The first line of each test case contains a single integer n (1≤n≤105).
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤109).
It is guaranteed that the sum of n over all test cases doesn't exceed 3⋅105.
第一行包含一个整数 t(1≤t≤10000),表示测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤105)。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)。
保证所有测试用例的 n 之和不超过 3⋅105。
输出格式
For each test case, print "YES" (without quotes) if it is possible to erase the whole sequence using the aforementioned operation, print "NO" (without quotes) otherwise. You can print each letter in any register (upper or lower).
对于每个测试用例,如果可以使用上述操作将整个序列完全删除,则输出 "YES"(不带引号);否则输出 "NO"(不带引号)。每个字母可使用大写或小写形式输出。
输入输出样例
输入#1
5 3 1 2 3 1 2 2 7 7 10 384836991 191890310 576823355 782177068 404011431 818008580 954291757 160449218 155374934 840594328 8 6 69 696 69696 696969 6969696 69696969 696969696
输出#1
YES NO YES YES NO
说明/提示
In the first test case, YouKn0wWho can perform the following operations (the erased elements are underlined): [1,2,3]→[1,3]→[3]→[].
In the second test case, it is impossible to erase the sequence as i can only be 1, and when i=1, a1=2 is divisible by i+1=2.
在第一个测试用例中,YouKn0wWho 可以执行以下操作(被删除的元素用下划线标出):[1,2,3]→[1,3]→[3]→[].
在第二个测试用例中,无法删除该序列,因为此时 i 只能为 1,而当 i=1 时,a1=2 能被 i+1=2 整除。
输入解题思路,AI测评打分。不知道怎么写?