欢迎加入西电微软俱乐部招新群 588166170,做出福利题,免技术部第一次面试且赠送“福利”海报或小礼品~~~~
Xidian Online Judge WebBoard
[ New Thread ]
Problem 1019 >> 测试10^8,严重超时,怎么改进呢?
14030110093 @ 2015-05-03 17:05:56
[ Quote ] [ Edit ] [ Delete ] 1#
#include <stdio.h>

long run(long a)
{
long i;
i = 0;
while(a > 4)
{
i += a/5;
a /= 5;
}
return i;
}

int main ()
{
long m,n=0,k=0;
int a,b=0;
scanf("%d",&a);
while(b < a)
{
n=0;
scanf("%ld",&m);
for(k = 1;n < m; k+=5)
{
n = run(k);
}
printf("%ld\n",k-6);
++b;
}
}
wanxiaowei @ 2015-05-03 17:55:13
[ Quote ] [ Edit ] [ Delete ] 2#
首先,看得出来你最近刷题很努力,这挺好的,其次,如果超时了,想想看有没有什么更巧的方法,方法不难,仔细想能想出来,再次,如果WA了,自己想办法出数据,debug,这本身就是写程序的一部分,而不要把代码贴上来找人看
14030110093 @ 2015-05-03 21:45:14
[ Quote ] [ Edit ] [ Delete ] 3#
。。。好吧
02129007 @ 2015-05-06 13:04:18
[ Quote ] [ Edit ] [ Delete ] 4#
还有一点。如果你仔细读了主页,就会发现不推荐使用long来定义。
[Top] [Previous Page] [Next Page]
Anything about the Problems, Please Contact Admin:admin
All Copyright Reserved 2010-2014 Xidian ACM Online Judge TEAM
GPL2.0 2003-2014 HUSTOJ Project TEAM