主题:变形joseph遇到奇怪的问题,帮忙看一下
program joseph(input,output);
const
n=26;
var
i,j,k,m,t,total:longint;
a:array[1..n]of longint;
begin
assign(input,'joseph.in');
assign(output,'joseph.out');
reset(input);
rewrite(output);
read(k);
for i:= 1 to (2*k) do
a[i]:=1;
m:=k+1;
total:=0;
t:=0;
i:=0;
repeat
t:=0;
repeat
begin
i:=i+1;
if i> (2*k)then i:=i-(2*k);
t:=t+a[i];
end;
until t=m ;
if i<=k then begin
m:=m+1;
total:=0;
for i:=1 to (2*k) do
a[i]:=1;
i:=0;
end;
if i>k then begin
total:=total+1;
a[i]:=0;
end;
until total=k;
write(m);
close(input);
close(output);
end.
这是一道变形joseph问题,但奇怪的是一旦输入大于10,就好象直接进入死循环,超时也就算拉,却永不了结.(1..9都顺利过关),(10..12就挂掉){数据就1..12[color=FFFF00]}{主要看一下为何10..12死机}[/color]
const
n=26;
var
i,j,k,m,t,total:longint;
a:array[1..n]of longint;
begin
assign(input,'joseph.in');
assign(output,'joseph.out');
reset(input);
rewrite(output);
read(k);
for i:= 1 to (2*k) do
a[i]:=1;
m:=k+1;
total:=0;
t:=0;
i:=0;
repeat
t:=0;
repeat
begin
i:=i+1;
if i> (2*k)then i:=i-(2*k);
t:=t+a[i];
end;
until t=m ;
if i<=k then begin
m:=m+1;
total:=0;
for i:=1 to (2*k) do
a[i]:=1;
i:=0;
end;
if i>k then begin
total:=total+1;
a[i]:=0;
end;
until total=k;
write(m);
close(input);
close(output);
end.
这是一道变形joseph问题,但奇怪的是一旦输入大于10,就好象直接进入死循环,超时也就算拉,却永不了结.(1..9都顺利过关),(10..12就挂掉){数据就1..12[color=FFFF00]}{主要看一下为何10..12死机}[/color]