The Miracle and the Sleeper solution codeforces
You are given two integersand , . Find the largest possible value of over all pairs of integers for which .
As a reminder,is a remainder we get when dividing by . For example, .
Each test contains multiple test cases.
The first line contains one positive integer, denoting the number of test cases. Description of the test cases follows.
The only line of each test case contains two integers, ( ).
For every test case, output the largest possible value ofover all pairs of integers for which .
4 1 1 999999999 1000000000 8 26 1 999999999
0 1 12 499999999
In the first test case, the only allowed pair is, for which .
In the second test case, the optimal choice is pair, for which .
Solution: Click here