讨论 / 有问题……帮个忙……(274)
typhoon 2010-06-19 21:14:00
点我顶贴 收藏 删除
program tt;

var i,n,s,a,j:longint;

t,r:string;

begin

readln(n);

s:=1;

for i:=2 to n do begin

s:=s*i;

str(s,t);

a:=length(t);

repeat

if t[a]=’0’ then a:=a-1;

until t[a]<>’0’;

val(t[a],s,j);

end;

write(s);

readln;

end.

测试结果1: 测试结果错误.错误结果为:2

正确结果应为:6

测试结果2: 通过本测试点|有效耗时157:ms

测试结果3: 测试结果错误.错误结果为:6

正确结果应为:4

测试结果4: 测试结果错误.错误结果为:4

正确结果应为:8

测试结果5: 测试结果错误.错误结果为:4

正确结果应为:8

测试结果6: 测试结果错误.错误结果为:2

正确结果应为:4

测试结果7: 测试结果错误.错误结果为:6

正确结果应为:4

测试结果8: 通过本测试点|有效耗时329:ms

测试结果9: 测试结果错误.错误结果为:2

正确结果应为:4

测试结果10: 测试结果错误.错误结果为:2

正确结果应为:6

#1 wish@2008-09-14 22:27:00
回复 删除
You should not just emulate the process but have to find a mathematical algorithm.

Hint: Think about which factors may consult a factor 10.

#2 binarie@2008-09-14 22:47:00
回复 删除
If you insist on emulation, there are still amount of ways....

the following code will do this correctly:

-------------------------------------

program p274;

var

i,n:longint;

t,z:qword;

begin

readln(n);

z:=1;

for i:=1 to n do

begin

z:=z*i;

t:=z;

while (t mod 10=0) do

t:=t div 10;

z:=t mod 10000;

t:=t mod 10;

end;

writeln(t);

end.

-------------------------------------

#3 Zx.MYS@2008-09-15 00:04:00
回复 删除
- -鸟语……
#4 hjqlty@2010-06-19 21:14:00
回复 删除
无语。。。。。。。。。。。。。。。。。。
查看更多回复
提交回复