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

刚过的,WA的不行了,觉得排序以后DP比较好吧.

Posted by nuanran at 2006-08-14 23:34:49 on Problem 2969
In Reply To:二维,不需要记录路径 Posted by:xfxyjwf at 2006-08-14 23:18:19
> 先算出各个数字出现的次数
> 不妨假设最后一位是0(是5的情况同样处理)
> 去掉这个0后,求用剩下的数字组成模3余0的最大数,实际上就是求一个组合,
> 使得所有数的和模3余0,组合里的数越多越好,大的数越多越好.
> 设f[i][j]表示只取0,1,...,i中的数且和模3余j的最优选法(就是选得最多)
> 显然f[0][0] = count[0], f[0][1] = -INF, f[0][2] = -INF;
> f[i][j] = Max{f[i-1][(j-k*i)%3] + k}, k = 0,1,...,count[i]
> f[9][0]是除去最后一位后的最大长度.
> 求出了f[][],就可以倒推出9最多多少个,8最多多少个
> 然后按从大到小输出,跟上一个0
> 末位是5的情况同上,求f[9][1]即可

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