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 5l2 at 2008-07-20 11:12:37 on Problem 2142 and last updated at 2008-07-20 11:13:16
大概意思 给定 a b k找到满足ax+by=k 的x,y 令|x|+|y|最小(等时令a|x|+b|y|最小)不妨a 〉b

先用扩展欧几里得算法求出 一组解 x0,y0

通解可以表示为x=x0+b/d *t  y=y0-a/d *t

|x|+|y|=|x0+b/d *t |+|y0-a/d *t| 简单分析一下可知这个关于t的函数的最小值应该在t零点附近(因为要求t为整数)取到,再进一步考虑知道在   y0*d/a 附近的两整点里取。故直接验证这两点即可。

http://hi.baidu.com/5l2%5F/blog/item/a0381951b5738a1e367abef0.html


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