#include <stdio.h>
#include<string.h>
#include<math.h>
void main()
{
int i,p,q,r;
int N;
int B;
double P,Q,R;
printf("please input N and the 3 numbers in each team and 1<=p,q,r<1000\n");
scanf("%d",&N);// scanf("%d",N); this is the old version
for(i=0;i<N;i++)
{
// scanf("%d \0 %d %d",&p,&q,&r);
scanf("%d %d %d",&p,&q,&r);
for(B=2;B<=16;B++)
{
P=(p/100)*pow(B,2)+(p%100)/10*pow(B,1)+(p%100%10)*pow(B,0);
Q=(q/100)*pow(B,2)+(q%100)/10*pow(B,1)+(q%100%10)*pow(B,0);
R=(r/100)*pow(B,2)+(r%100)/10*pow(B,1)+(r%100%10)*pow(B,0);
if(P*Q==R)
{
printf("%d\n",B);
break;
}
}
while(!B)
printf("0");
}
}
#include<string.h>
#include<math.h>
void main()
{
int i,p,q,r;
int N;
int B;
double P,Q,R;
printf("please input N and the 3 numbers in each team and 1<=p,q,r<1000\n");
scanf("%d",&N);// scanf("%d",N); this is the old version
for(i=0;i<N;i++)
{
// scanf("%d \0 %d %d",&p,&q,&r);
scanf("%d %d %d",&p,&q,&r);
for(B=2;B<=16;B++)
{
P=(p/100)*pow(B,2)+(p%100)/10*pow(B,1)+(p%100%10)*pow(B,0);
Q=(q/100)*pow(B,2)+(q%100)/10*pow(B,1)+(q%100%10)*pow(B,0);
R=(r/100)*pow(B,2)+(r%100)/10*pow(B,1)+(r%100%10)*pow(B,0);
if(P*Q==R)
{
printf("%d\n",B);
break;
}
}
while(!B)
printf("0");
}
}