- 字符串还原
- 2016-10-30 17:14:12 @
···
var n,i,j:longint;
s1,s2,s3:ansistring;
procedure print(a:ansistring);
var i:longint;
begin
for i := n downto 1 do write(a[i]);
end;
function pd(a,b:string):longint;
begin
if abs(ord(a[1]) - ord(b[n])) <= 6 then pd := abs(ord(a[1]) - ord(b[n]))
else if (ord(a[1]) <= ord('f')) and (ord(b[n]) >= ord('u')) then pd := ord(a[1]) - ord('a') + ord('z') - ord(b[n]) + 1
else if (ord(a[1]) >= ord('u')) and (ord(b[n]) <= ord('f')) then pd := ord('z') - ord(a[1]) + 1 + ord(b[n]) - ord('a')
else pd := -maxlongint div n;
end;
begin
readln(n);
if n = 0 then exit;
readln(s1);
readln(s2);
readln(s3);
if pd(s1,s2) = pd(s3,s2) then print(s2)
else if pd(s1,s3) = pd(s2,s3) then print(s3)
else if pd(s2,s1) = pd(s3,s1) then print(s1);
end.
···
what happen?