The problem goes like this: You have a book with n ( n<=10^7 ) pages. You can flip exactly X pages to the right and exactly Y pages to the left. If you're initially on page 1, what is the minimum number of moves to go from page 1 to page A? (**100 test cases**)
You can find the problem Here( UVA 11312- Flipping Frustration ).
I will be very thankful if you provide me with a solution.