Var
s:string;
t,c:string;
function Palindrome(s:string):boolean;
var
i:integer;
begin
for i:= 1 to s.Length div 2 do
if s[i] <> s[s.Length-i+1] then
begin
Palindrome:=false;
exit;
end;
Palindrome:= true;
end;
begin
Readln(s);
c:=copy(s,1, s.Length div 2);
t:=copy(s,s.Length div 2 + 1, s.Length);
if (Palindrome(s))and(Palindrome(c))and(Palindrome(t)) then
Writeln('YES')
else
Writeln('NO');
end.
<u>Пример:</u>
ACAACA
YES
Var
S1,S2,S3:string;
i:integer;
Begin
Write('S1: ');ReadLn(S1);
Write('S2: ');ReadLn(S2);
For i:= 1 to Length(S1) do
if i mod 2 = 0 then S3:=S3+S2
else S3:=S3+S1[i];
S1:=S3;
Write('S1: ',S1);
End.
Пример:
S1: 123456789
S2: ||
S1: 1||3||5||7||9
Псевдокод:
N - номер квартиры
iTop = N div 4;
if(N mod 4 > 0) iTop++;
Npd = (iTop-1) div 9 + 1; // Подъезд
Net = (iTop-1) mod 9 + 1; // Этаж