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,哪个高手能指点一下吗?#include<stdio.h> #include<stdlib.h> long int jiecheng(long int m,long int n) { long int i,s=n; for(i=1;i<m;i++) s=s*n; return s; } int main() { long int b,n,m,i,k,min; do { min=10000000; scanf("%ld%ld",&b,&n); for(i=0;;i++) { m=jiecheng(n,i); k=abs(m-b); if(min>=k) min=k; else break; } printf("%ld\n",i-1); }while(b!=0&&n!=0); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator