function p(a:longint):longint;
var b:longint;
begin
for b := 2 to trunc(sqrt(a)) do if a mod b = 0 then begin
p := b;exit;
end;
p := a;
end;
begin
readln(a);
b := p(a);write(b);a := a div b;
while a > 1 do begin
b := p(a);
write(' ',b);a := a div b;
end;
end.
状态: Unaccepted
测评机: Xeost[5]
得分: 90分
提交日期: 2013-7-20 12:37:00
有效耗时: 1437毫秒
测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 通过本测试点|有效耗时156ms
测试结果3: 通过本测试点|有效耗时156ms
测试结果4: 通过本测试点|有效耗时157ms
测试结果5: 通过本测试点|有效耗时156ms
测试结果6: 通过本测试点|有效耗时156ms
测试结果7: 通过本测试点|有效耗时156ms
测试结果8: 通过本测试点|有效耗时172ms
测试结果9: 通过本测试点|有效耗时156ms
测试结果10: 运行错误|未定义错误编号|错误编号:106
状态: Unaccepted
测评机: Xeost[5]
得分: 90分
提交日期: 2013-7-20 12:37:00
有效耗时: 1437毫秒
测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 通过本测试点|有效耗时156ms
测试结果3: 通过本测试点|有效耗时156ms
测试结果4: 通过本测试点|有效耗时157ms
测试结果5: 通过本测试点|有效耗时156ms
测试结果6: 通过本测试点|有效耗时156ms
测试结果7: 通过本测试点|有效耗时156ms
测试结果8: 通过本测试点|有效耗时172ms
测试结果9: 通过本测试点|有效耗时156ms
测试结果10: 运行错误|未定义错误编号|错误编号:106
原来要改成int64。。。
var a,b:int64;
function p(a:int64):int64;
var b:int64;
begin
for b := 2 to trunc(sqrt(a)) do if a mod b = 0 then begin
p := b;exit;
end;
p := a;
end;
begin
readln(a);
b := p(a);write(b);a := a div b;
while a > 1 do begin
b := p(a);
write(' ',b);a := a div b;
end;
end.
结果编译错误。。。这下咋办
var
n:int64;
i,max,kl:longint;
t:boolean;
function op(kl:longint):longint;
var
i:longint;
begin
for i:=2 to kl-1 do
if kl mod i=0 then exit(0);
exit(1);
end;
begin
read(n);
for i:=2 to n-1 do
if n mod i=0 then
begin
t:=false;
break;
end;
if t then write(n);
kl:=2;
while n>1 do
begin
while n mod kl=0 do
begin
n:=n div kl;
write(kl,' ');
end;
inc(kl);
while op(kl)=0 do
inc(kl)
end;
readln;
readln;
end.参考程序
var
a,i:int64;
begin
read(a);
while a<>1 do
begin
i:=2;
while i<=a do
begin
if a mod i=0 then begin
write(i,' ');
a:=a div i;
break;
end;
i:=i+1;
end;
end;
end.