为什么我会收到 NZEC 错误?
我在 Pascal 中工作,我不明白为什么在提交问题时收到 NZEC(非零退出代码)错误。在我的电脑上它运行完美。你能给我你的意见吗?
program super_factor_sum;
var k,i,j,s:longint; f,g:text;
function prim(x:integer):boolean; var d:longint;
begin
prim:=true;
for d:=2 to x div 2 do if x mod d=0 then prim:=false;
end;
begin assign(f,'input.txt'); reset(f); assign(g,'output.txt'); rewrite(g);
while not eof(f) do
begin readln(f,k); s:=0; i:=2;
while (k<>1) or (i<=k) do
begin if (prim(i)) and (k mod i=0) then
begin j:=0;
repeat k:=k div i; j:=j+1;
until k mod i<>0;
s:=s+i*j; i:=i+1;
end
else i:=i+1;
end;
write(s); writeln(g,s);
end;
close(f); close(g);
end.
I'm working in Pascal, I don't understand why I'm getting an NZEC (Non Zero Exit Code) error when I'm submitting my problem. On my PC it works perfectly. Can you give me your opinion please?
program super_factor_sum;
var k,i,j,s:longint; f,g:text;
function prim(x:integer):boolean; var d:longint;
begin
prim:=true;
for d:=2 to x div 2 do if x mod d=0 then prim:=false;
end;
begin assign(f,'input.txt'); reset(f); assign(g,'output.txt'); rewrite(g);
while not eof(f) do
begin readln(f,k); s:=0; i:=2;
while (k<>1) or (i<=k) do
begin if (prim(i)) and (k mod i=0) then
begin j:=0;
repeat k:=k div i; j:=j+1;
until k mod i<>0;
s:=s+i*j; i:=i+1;
end
else i:=i+1;
end;
write(s); writeln(g,s);
end;
close(f); close(g);
end.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
避免 SPOJ 中的 Erlang 出现 NZEC 错误
“模块名称始终必须是测试,入口点应该是函数 main ,例如,编译后应该以测试:main()" 的形式运行。
Avoid NZEC error in Erlang in SPOJ
"module name always has to be tested and the entry point should be function main . For example, after compilation it should be run as tested:main()"