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<stdio.h> #include<math.h> char a[7],b[7],c[7]; int suit(long p,long q,long r,int base) { long x,y,z; int i,j,k,l,max; x=y=z=max=0; for(i=0;p;i++) { if((p%10)>max) max=p%10; a[i]=p%10+'0'; p/=10; } a[i]='\0'; for(j=0;q;j++) { if((q%10)>max) max=q%10; b[j]=q%10+'0'; q/=10; } a[j]='\0'; for(k=0;r;k++) { if((r%10)>max) max=r%10; c[k]=r%10+'0'; r/=10; } c[k]='\0'; for(l=i-1;l>=0;l--) x+=(a[l]-'0')*pow(base,l); for(l=j-1;l>=0;l--) y+=(b[l]-'0')*pow(base,l); for(l=k-1;l>=0;l--) z+=(c[l]-'0')*pow(base,l); if(max>=base) return 0; else { if((x*y)==z) return 1; else return 0; } } int multiply(long p,long q,long r) { int i; for(i=2;i<=16;i++) if(suit(p,q,r,i)) return i; return 0; } main() { int t,i; long p,q,r; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%ld%ld%ld",&p,&q,&r); printf("%d\n",multiply(p,q,r)); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator