Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我的某奇怪做法 求解释。。。。。

Posted by Master_Chivu at 2010-11-15 21:23:57 on Problem 2346
const	maxm=5;
	max=maxm*9;
        catalan:array[0..5]of longint=(1,1,1,2,5,14);
var	n,m,i,j,s1,t1,s2,t2,k,p:longint;
	opt:array[0..maxm,-max..max]of int64;
begin
assign(input,'Lucky.in'); reset(input);
assign(output,'Lucky.out'); rewrite(output);
readln(n);
m:=n div 2;
for i:=-9 to 9 do
	opt[1,i]:=10-abs(i);
for i:=2 to m do
	begin
	t1:=i*9; s1:=-t1;
	for j:=s1 to t1 do
		begin
		opt[i,j]:=0;
		if j>0
			then begin
			t2:=9*(i-1);
			s2:=j-t2;
			end
			else begin
			s2:=-9*(i-1);
			t2:=j-s2;
			end;
		for k:=1 to i-1 do
			for p:=s2 to t2 do
				opt[i,j]:=opt[i,j]+opt[i-k,p]*opt[k,j-p];
		end;
	end;
writeln(opt[m,0] div catalan[m]);
close(input); close(output);
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator