DY and DX received an array generator on the occasion of Codigo and being the math buffs that they are, a math game was quickly formulated. Consider an array A which consists of N elements A1,A2,...,AN. An index i of the given array is considered good if Ai=i. DY wins the game if the count of good indices in the array is co-prime to the size of the array, while DX wins the other way around. Given an array, find out who wins the game
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N, i;
int T;
cin >> T;
while (T--)
{
cin >> N;
int a[N];
int count=0;
int p=0;
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
for (int i = 0; i < N; i++)
{
p++;
if (a[i] == p) // a1 == 0 a2 == 1 a3 == 2 a4 == 3 a5 4 a6 5
count++;
}
if(__gcd(count,N)==1)
cout<<"DY"<<endl;
else
cout<<"DX"<<endl;
}}