the question for the solution below is -
Now…
The following code is working fine for the test cases but giving wrong answer on submission.
What is the mistake that i am doing?
Is my method wrong for the question?
#include<iostream>
#include<stdio.h>
using namespace std;
int func(long long int a,long long int b)
{
int freq=0;
if(a<b)
swap(a,b);
if(a%b==0)
freq++;
else
{
freq++;
freq+=func(b,a%b);
}
return freq;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
long long int a,b;
int arr[n];
int sum=0;
for(int i=0;i<n;i++)
{
cin>>a;
cin>>b;
arr[i]=func(a,b);
sum+=arr[i];
}
if(sum%2!=0)
cout<<"YES\n";
else
cout<<"NO\n";
}
}