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 |
实在不知道哪里出问题了哪位高手帮看一下,谢谢啦 #include<iostream.h> #include<string.h> #include<memory.h> void getmax( char a[10] , int &max ) { for( int i = 0 ; i < strlen(a) ; i++ ) { if ( a[i]-'0' > max ) max = a[i]-'0'; } } void main() { int n,p , i,j,lena,lenc,lenb,max ,ok,temp[1000],con; char a[100],b[100],c[100] ; cin >> n ; while(n--) { cin >> a >> b >> c ; max = 0 ; lenc = strlen(c) ; lena = strlen(a) ; lenb = strlen(b) ; getmax( a , max ) ; getmax( b , max ) ; getmax( c , max ) ; ok = 0 ; for( p = 2 ; p <= 16 && ok == 0 ; p++ ) { memset( temp , 0 , sizeof(temp)); for( i = 0 ; i < lena ; i++ ) { con = 0 ; for( j = 0 ; j < lenb ; j++ ) { temp[i+j] += (a[i]-'0')*(b[j]-'0') ; con = temp[i+j] / p ; temp[i+j] %= p ; } temp[i+j] = con ; } ok = 1 ; for( i = 0 ; i < lenc ; i++ ) { if ( c[lenc-i-1]-'0' != temp[i] ) { ok = 0 ; break ; } } } p-- ; if ( p >= 16 ) p = 0 ; cout << p << endl ; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator