найдите максимально возможное количество цветов в палитре, если известно,что размер изображения 291*291,а для хранения этого изображения выделено 32КБ памяти нужно
дешифровки: Const sh = '_.,'; Var St : String; i : Integer; Function DeCode(S : String; Tabl : String; k : Integer) : String; Var j,n : Integer; Begin For j:=1 to Length(S) do Begin n:=Pos(S[j],sh); If n>0 then Begin n:=n+k; While n>Length(sh) do n:=n-Length(sh); While n<=0 do n:=n+Length(sh); S[j]:=sh[n]; end end; DeCode:=S; end; Begin St:='ЗЫФЙГФШРЦ . ШД'; Writeln(Decode(St,sh,-6)); //For i:=-10 to 10 do Writeln(Decode(St,sh,i)); end.
Var a:array[1..3,1..3] of integer; t:array[0..2] of boolean; k:array[0..2] of integer; i,j:integer; res:boolean;
begin for i := 1 to 3 do for j := 1 to 3 do read(a[i,j]); for i := 0 to 2 do begin k[i] := 0; t[i] := false; end;
for i := 1 to 3 do for j := 1 to 3 do k[a[i,j]] := k[a[i,j]] + 1;
for i := 1 to 3 do begin if (a[i,1] = a[i,2]) and (a[i,2] = a[i,3]) then t[a[i,1]] := true; if (a[1,i] = a[2,i]) and (a[2,i] = a[3,i]) then t[a[1,i]] := true; end; if (a[1,1] = a[2,2]) and (a[2,2] = a[3,3]) then t[a[2,2]] := true; if (a[3,1] = a[2,2]) and (a[2,2] = a[1,3]) then t[a[2,2]] := true;
res := true;
if (k[1] - k[2] > 1) or (k[1] - k[2] < 0) then res := false;
if t[1] and ( t[2] or (k[1] = k[2]) ) then res := false;
if res then writeln('YES') else writeln('NO') end.
дешифровки:
Const sh = '_.,';
Var
St : String;
i : Integer;
Function DeCode(S : String; Tabl : String; k : Integer) : String;
Var j,n : Integer;
Begin
For j:=1 to Length(S) do
Begin
n:=Pos(S[j],sh);
If n>0 then
Begin
n:=n+k;
While n>Length(sh) do n:=n-Length(sh);
While n<=0 do n:=n+Length(sh);
S[j]:=sh[n];
end
end;
DeCode:=S;
end;
Begin
St:='ЗЫФЙГФШРЦ . ШД';
Writeln(Decode(St,sh,-6));
//For i:=-10 to 10 do Writeln(Decode(St,sh,i));
end.
a:array[1..3,1..3] of integer;
t:array[0..2] of boolean;
k:array[0..2] of integer;
i,j:integer;
res:boolean;
begin
for i := 1 to 3 do
for j := 1 to 3 do
read(a[i,j]);
for i := 0 to 2 do
begin
k[i] := 0;
t[i] := false;
end;
for i := 1 to 3 do
for j := 1 to 3 do
k[a[i,j]] := k[a[i,j]] + 1;
for i := 1 to 3 do
begin
if (a[i,1] = a[i,2]) and (a[i,2] = a[i,3]) then
t[a[i,1]] := true;
if (a[1,i] = a[2,i]) and (a[2,i] = a[3,i]) then
t[a[1,i]] := true;
end;
if (a[1,1] = a[2,2]) and (a[2,2] = a[3,3]) then
t[a[2,2]] := true;
if (a[3,1] = a[2,2]) and (a[2,2] = a[1,3]) then
t[a[2,2]] := true;
res := true;
if (k[1] - k[2] > 1) or (k[1] - k[2] < 0) then
res := false;
if t[1] and ( t[2] or (k[1] = k[2]) ) then
res := false;
if res then
writeln('YES')
else
writeln('NO')
end.