|
|
вернуться в форумWhy it does not work? program permutation; var m,p : array [1..1000] of word; N,i,j : integer; k : longint; quit : boolean; Begin readln(N); for i := 1 to N do read(p[i]); for i := 1 to n do m[i]:=p[i]; k:=1; quit := false; while true do begin j:=0; repeat j:=j+1; quit := m[j]=j; until (quit=false) or ((i=n) and (m[i]=i)); if quit then break; k:=k+1; for i := 1 to n do m[i] := p[m[i]]; end; writeln(K); end. |
|
|