ac1141.pas
来自「这是在网络上搜集到的在东京大学的ACM上面解决的一些题目的源码」· PAS 代码 · 共 33 行
PAS
33 行
program tju1141;
const
maxn=49;
var
count:array[0..maxn]of qword;
i,x,y,z:shortint;
function h(a:qword;b:byte):qword;
var
i:byte;
begin
h:=1;
for i:=1 to b do
h:=h*(a+i-1) div i;
end;
begin
count[0]:=1;
for i:=1 to maxn do begin
x:=0;z:=i-1;
repeat
if x<>z then inc(count[i],h(count[x],2)*count[z]) else inc(count[i],h(count[x],3));
inc(x);dec(z,2);
until z<0;
for x:=0 to (i-1) div 3-1 do
for y:=x+1 to (i-x-2) div 2 do
inc(count[i],count[x]*count[y]*count[i-1-x-y]);
end;
repeat
read(i);
writeln(count[i]);
until seekeof;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?