Pagini recente » Cod sursa (job #2151118) | Cod sursa (job #429522) | Cod sursa (job #2702426) | Cod sursa (job #1209778) | Cod sursa (job #309739)
Cod sursa(job #309739)
program p1;
type vect=array[1..1000] of integer;
var f,g:text;
a:vect;
i,n,m,x:integer;
function gata(a:vect):boolean;
var j:integer;
begin
gata:=true;
for j:=1 to n do
if a[j]=0 then begin
gata:=false;
break;
end;
end;
begin
assign(f,'circle.in');reset(f);
assign(g,'circle.out');rewrite(g);
readln(f,n,m);
i:=1;
while not gata(a) do
begin
x:=0;
while x<m do
begin
if a[i]=0 then x:=x+1;
if x=m then begin
write(g,i,' ');
a[i]:=1;
end;
i:=i+1;
if i=n+1 then i:=1;
end;
end;
for i:=1 to n do
a[i]:=i;
close(f);
close(g);
end.