program grey; {Internet_Olimp informat VIPPO 2011-2012 tur2 zavd2} {Kod ychasnuka B3292} {mova program Pascal} {seredovushe Delphi7} {$APPTYPE CONSOLE} uses SysUtils; Type TKodGrey = array [0..1023, 1..10] of integer; var f:text; n:integer; binStep:array [0..10] of integer = (1,2,4,8,16,32,64,128,256,512,1024); kod: TKodGrey; i,j,p,k:integer; procedure generKodGrey(p,k:integer; var mas:TKodGrey); var i,j:integer; begin for i:= 0 to binStep[p-1]-1 do for j := 1 to p-1 do mas[binStep[p]-1-i,j]:=mas[i,j]; for i:= 0 to binStep[p-1]-1 do mas[i,p]:=0; for i:= binStep[p-1] to binStep[p]-1 do mas[i,p]:=1; end; begin assign(f,'grey.dat'); reset(f); read(f,n); close(f); k:=0; for j:=0 to 10 do if (binStep[j-1]<=n) and (n0) and (kod[n,j]=0) do j:=j-1; if j=0 then write(f,0) else for i:=j downto 1 do write(f,kod[n,i]); close(f); end.