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

所有线路的bus两两匹配,如果可以碰到加入同一集合,最后看是否只有1个集合

Posted by liymouse at 2022-02-01 22:05:29 on Problem 1370
设i线路周期为ti,j线路周期为tj,ij某个公共站k
i线某bus到k要走a个站
j线某bus到k要走b个站

ti * x + a = tj * y + b

只要有xy非负整数解,则这2个bus肯定可以在k站碰面
有解条件为 abs(a-b) % gcd(x,y) == 0

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