/** *Author: xiaoran *Time: ****************** *Solution: * */ #include #include using namespace std; int A[27],B[27],C[27]; int Judge(int a,int b,int c){ for(int i=1;i*a>t; while(t--){ memset(A,0,sizeof(A)); memset(B,0,sizeof(B)); memset(C,0,sizeof(C)); cin>>a>>b>>c; for(int i=0;i>s>>x; A[s-'A']=x; } for(int i=0;i>s>>x; B[s-'A']=x; } for(int i=0;i>s>>x; C[s-'A']=x; } int i,j=0,k=0,ok=1; for(i=0;i<26;i++){ if(A[i]==0&&B[i]==0&&C[i]==0){ continue; } else if(A[i]==0&&B[i]==0&&C[i]!=0){ ok=0; break; } else if(A[i]==0&&B[i]!=0){ if(C[i]%B[i]==0){ k=C[i]/B[i]; } else { ok=0; } } else if(A[i]!=0&&B[i]==0){ if(C[i]%A[i]==0) j=C[i]/A[i]; else ok=0; } else{ j=Judge(A[i],B[i],C[i]); if(j==-1){ ok=0; break; } k=(C[i]-A[i]*j)/B[i]; } } //cout<