ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1252. Sorting the Tombstones

Please tell me how to prove!
Posted by PSV 23 Oct 2006 23:14
I've AC but I can't undestand how prove that GCD gives right answer?
Re: Please tell me how to prove!
Posted by PSV 26 Oct 2006 21:12
Come ON! Please I want to know
Re: Please tell me how to prove!
Posted by Denis Koshman 6 Aug 2008 16:11
Every stone may go to positions pos+K*x, pos - its original place, x - some integer, K - sought value. If for every stone its designated position is reachable (i.e. K divides abs(dst-src)), then stones are sortable - just bubble-sort each of K chains, and they are not sortable otherwise. So, the answer is GCD(dst-src) for all stones.

Edited by author 06.08.2008 16:12