about summary refs log tree commit diff
path: root/others/volume1/044.pas
blob: 1ac29fe3b45f2a31f9355a5b3a6a52f407eead88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var
  n, n0, m, m0, i: int16;
  a: array of int16;
  b: array of boolean;

begin
  readln(n, m);
  n0 := n;
  setlength(a, n);
  setlength(b, n);
  for i := 0 to n - 1 do
    b[i] := true;
  i := -1;
  while n0 > 0 do
    begin
      m0 := m;
      while m0 > 0 do
        begin
          repeat
            if i < n - 1 then
              inc(i)
            else
              i := 0
          until b[i];
          dec(m0)
        end;
      b[i] := false;
      a[n - n0] := i + 1;
      dec(n0)
    end;
  for i in a do
    write(i, ' ');
  writeln
end.