| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
水题,要用龍龍int#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
vector<int> digitA, digitB, digitC;
int mxDigit = 0;
while(a > 0){
int A = a%10;
digitA.push_back(A);
if(A > mxDigit) mxDigit = A;
a/=10;
}
while(b > 0){
int B = b%10;
digitB.push_back(B);
if(B > mxDigit) mxDigit = B;
b/=10;
}
while(c > 0){
int C = c%10;
digitC.push_back(C);
if(C > mxDigit) mxDigit = C;
c/=10;
}
int wsA = digitA.size(), wsB = digitB.size(), wsC = digitC.size();
bool get = 0;
for(int BB = mxDigit+1; BB <= 16; BB++){
long long int aa = 0, bb = 0, cc = 0;
for(int j = wsA-1; j >= 0; j--){
aa*=BB;
aa+=digitA[j];
}
for(int j = wsB-1; j >= 0; j--){
bb*=BB;
bb+=digitB[j];
}
for(int j = wsC-1; j >= 0; j--){
cc*=BB;
cc+=digitC[j];
}
if(aa*bb==cc){
get = 1;
printf("%d\n", BB);
break;
}
}
if(!get){
printf("0\n");
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator