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

先把W加上(3^20-1)/2,再化成三进制来简化问题。

Posted by forlfs at 2013-04-05 11:24:45 on Problem 1702 and last updated at 2013-04-05 11:25:38
其实,如果把右端重量减去左端重量作为所求重量,则-(3^20-1)/2<=W<=(3^20-1)/2,很明显跟三进制的表示范围0~3^20-1一样大。
所以,先把W加上(3^20-1)/2,再化成三进制。对于某一位,如果为0就放左端,如果为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