2008 NPSC E. PK 賽
2008 NPSC 國中組初賽 E. PK 賽
/***************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
char a[5],b[5];
int tempa,tempb,n,a1,b1,c1;
while(scanf("%d ",&n)==1)
{
for(a1=0;a1<n;a1++)
{
gets(a);
gets(b);
if(strlen(a)<=5)
{
tempa=0;tempb=0;
for(b1=0;b1<strlen(a);b1++)
{
if(a[b1]=='O')
tempa++;
}
for(c1=0;c1<strlen(b);c1++)
{
if(b[c1]=='O')
tempb++;
}
if(tempa>=3&&tempa!=tempb&&tempa>tempb)
printf("A\n");
else if(tempb>=3&&tempa!=tempb&&tempa<tempb)
printf("B\n");
else
printf("NO\n");
}
else
{
tempa=0;tempb=0;
for(b1=0;b1<strlen(a);b1++)
{
if(a[b1]=='O')
tempa++;
}
for(c1=0;c1<strlen(b);c1++)
{
if(b[c1]=='O')
tempb++;
}
if(tempa>tempb&&strlen(a)==strlen(b))
printf("A\n");
else if(tempb>tempa&&strlen(a)==strlen(b))
printf("B\n");
else
printf("NO\n");
}
}
}
return 0;
}