This is my code in c++ for Guessing Game,plz help me as it gave wrong answer on codechef:-
#include
#include<string.h>
using namespace std;
long int t,n,m;
long int c;
int rs1[100000];
int rs2[100000];
int main()
{
cin>>t;
c=t;
while(t>0)
{
int alice=0,bob=0;
cin>>n>>m;
int tot=m*n;
int odd1,odd2,even1,even2;
if(n%2==0)
{
odd1=n/2;
even1=n-odd1;
}
else
if(n%2!=0)
{
odd1=(n+1)/2;
even1=n-odd1;
}
if(m%2==0)
{
odd2=m/2;
even2=m-odd2;
}
else if(m%2!=0)
{
odd2=(m+1)/2;
even2=m-odd2;
}
alice=(odd1*even2)+(odd2*even1);
int temp,n1,n2;
n1=alice;
n2=tot;
while(n1>0)
{
temp=n1;
n1=n2%n1;
n2=temp;
}
alice=alice/n2;
tot=tot/n2;
rs1[t]=alice;
rs2[t]=tot;
t--;
}
for(int i=c;i>=1;i--)
{
cout<<rs1[i]<<"/"<<rs2[i]<<"\n";
}
}