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 ly50247 at 2009-07-22 12:14:39 on Problem 2663
来一个数n,它比上一个数差2,而2能摆出三种情况,这样如果这个2和前面是分开的,这种情况是 f[n-2] * 3,剩下就要考虑不分开的情况,这也是关键。

仔细分析图可以看出每偶数个格都可以摆成不可分割的,这种情况必须是上下有一排全是横放的,也就是只有两种摆法,这就好办了。

	f[0] = 1;
	f[2] = 3;
	for (int i=4; i < 32; i++)
	{
		f[i] = 3 * f[i-2];
		int t = i;
		while (t >= 4)
		{
			f[i] += f[i-t] * 2;
			t -= 2;
		}
	}
	

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