Di-visible Confusion

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.

Input

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.

Output

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).

Example

input

Copy

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

output

Copy

YES
NO
YES
YES
NO

Note

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.

思路:题中要ai不能被整除i+1的去掉, 那么我们可以想怎样会删不掉呢?说明最起码它能整除i+1,因为这一题会移动ai的位置,所以最坏的情况它将能整除从2到i+1,那么还有一半的问题没有解决,就是假设n=1e5时,一个数要从2遍历到1e5+1,这必超时,2到i+1是成上的,当到 i 到22时相乘的最小公倍数就大于1e9了,所以这里假设让它遍历一百次。核心:由于遍历是从前到后的,所以只要有一个数无法被除掉,就一定无法将数组清0,能让i大于时所前100个数都被干掉了,100之后的位置我可以通过删除前面的位置与顺序一定能让它到100之内的任意一个数上,只要100之内的数有一个能让它不整除(即被删掉)那么我一定能移到(假设在100之前就有不能被删掉的,那么100之后的变毫无意义,100之后的操作全当放屁,无用)

#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
const int N=1e5+10;
int a[N];

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }

        bool ok=true;
        for(int i=1;i<=n;i++)
        {
            bool st=false;
            for(int j=2;j<=min(100,i+1);j++)
            {
                if(a[i]%j)
                {
                    st=true;
                    break;
                }
            }
            ok&=st;
        }
        if(ok)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值