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.
#include <iostream>
using namespace std;
int main()
{
long long int t;
cin >> t;
while (t--)
{
long long int n;
cin >> n;
int a[n];
for (long long int i = 1; i <= n; i++)
{
cin >> a[i];
}
// if(a[i]%(i+1) ==0)
long long int count = 1;
for (long long int i = 1; i <= n; i++)
{
if (a[i] % (i + 1) != 0) // 1 2 2 3 3 4
{
count++;
}
}
// cout<<count;
if (count != n)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
// cin>>a[i];
}