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 |
用你的范围写出来的代码是WA的,测试数据都过了(附Code)In Reply To:Re:提示大家一下,这道题输出不超过36 Posted by:RUNSLOWLY at 2008-10-09 13:39:25 #include<stdio.h> #include<math.h> int f(int n,int m) { int i,sum,j,all,k; i=1; sum=n; while(n/10>0) { i++; n=n/10; } k=0; for(j=0;j<i;j++) { all=sum%10; k+=all*(int)pow(m,j); sum=sum/10; } return k; } int main() { int p,q,r,i,time; scanf("%d",&time); while(time--) { scanf("%d%d%d",&p,&q,&r); for(i=2;i<=36;i++) { if(f(q,i)*f(p,i)==f(r,i)) { printf("%d\n",i); break; } } if(i>36) 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