讨论 / 第十个数据通不过!!!
hwy2013 2013-07-20 02:27:00
点我顶贴 收藏 删除
var a,b:longint;

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.

结果编译错误。。。这下咋办

#1 107229HR@2013-07-20 02:27:00
回复 删除
C++党路过

大概懂了,把int64变量做循环变量会CE,你把b改成longint差不多

#2 雨幻翼@2014-05-05 01:56:57
回复 删除
program project1;

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.参考程序

#3 969653002@2016-05-01 02:41:36
回复 删除
递归最好
#4 sbsbt@2018-08-02 03:54:23
回复 删除
不需要

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.

查看更多回复
提交回复