讨论 / 此贴已删……
fts96 2012-08-27 18:32:00
点我顶贴 收藏 删除
代码大意:算出n!的质因数分解,用2的数目减去5的数目然后把5的个数标为0,最后每个个数同时除以4然后算……怎么就错了呢……

状态: Unaccepted

测评机: Xeond[6]

得分: 80分

提交日期: 2012-8-28 9:17:00

有效耗时: 2125毫秒

测试结果1: 通过本测试点|有效耗时188ms

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

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

测试结果4: 通过本测试点|有效耗时187ms

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

正确结果应为:8

测试结果6: 通过本测试点|有效耗时250ms

测试结果7: 通过本测试点|有效耗时343ms

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

测试结果9: 通过本测试点|有效耗时313ms

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

正确结果应为:6

代码:

program rq274;

var

s:array[1..200000] of longint;

d:array[1..200000] of longint;

p,n:longint;

function su(x:longint):boolean;

var i:longint;

begin

for i:=2 to trunc(sqrt(x)) do

if x mod i=0 then exit(false);

exit(true);

end;

procedure init;

var

i,j:longint;

k:int64;

z:longint;

begin

readln(n);

p:=0;

fillchar(s,sizeof(s),0);

for i:=2 to n do

if su(i) then

begin

k:=i;

inc(p);

while k<=n do

begin

inc(s[p],n div k);

k:=k*i;

end;

d[p]:=i mod 10;

end;

s[1]:=s[1]-s[3];

s[3]:=0;

z:=1;

for i:=1 to p do s[i]:=s[i] mod 4;

for i:=1 to p do

for j:=1 to s[i] do

z:=(z*d[i]) mod 10;

writeln(z);

end;

begin

init;

end.

查看更多回复
提交回复