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 aoxboxcox at 2014-09-12 14:59:15 on Problem 1514 and last updated at 2014-09-12 14:59:36
据说暴力地枚举每种切法也能过,但更合理的算法应该是动态规划。

考虑下面两点
(1)原始矩形切i(1<=i<=p)刀的最优解一定是从切了(i-1)刀的最优解上再加一刀得到的。
(2)原始矩形切了i刀后,无论这前i刀是以何种顺序,留下的图形显然都是固定的。
于是,总状态数从原来的p!(暴力法)减少到了pow(2,p)个。
以上两点想通了,具体算法很简单,不再赘述了。

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