📄 travel.pas
字号:
program jsoi04_winter_a2;
var s1,s2:string;
procedure init;
begin
assign(input,'travel.in'); reset(input);
readln(s1); readln(s2); close(input);
end;
function check(f,l:string):boolean;
var i:byte;
begin
if length(f)=0 then check:=true
else
begin
check:=true;
check:=f[1]=l[length(l)];
for i:=2 to length(f) do
if pos(f[i],l)=0 then check:=false;
end
end;
function count(first,last:string):longint;
var i,len:byte; t:longint;
lf,ll,rf,rl:string;
begin
len:=length(last); t:=0;
if len<=1 then count:=1
else
begin
for i:=len-1 downto 0 do
begin
lf:=copy(first,2,i);
ll:=copy(last,1,i);
rf:=copy(first,i+2,len-1-i);
rl:=copy(last,i+1,len-1-i);
if check(lf,ll) and check(rf,rl) then
t:=t+count(lf,ll)*count(rf,rl);
end;
count:=t;
end;
end;
begin
init;
assign(output,'travel.out');rewrite(output);
writeln(count(s1,s2)); close(output)
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -