adplus-dvertising

Maximize Difference CodeChef Solution

We Are Discuss About CODECHEF SOLUTION

Maximize Difference CodeChef Solution

Maximize Difference CodeChef Solution

Chef has two numbers N and M. He calls a pair of numbers (A, B) good if it satisfies the following conditions:

  • 1 \le A, B \le M
  • \gcd(A, B) \ge N

Chef wants to find a good pair (A, B) such that the value of |A РB| is maximized. Can you help Chef? (Here |X| represents the absolute value of X).

If there are multiple good pairs for which the value of |A РB| is maximized, you can print any of them. It can be proved that under the given constraints, at least one good pair always exists.

Input Format

  • The first line contains a single integer¬†T¬†‚ÄĒ the number of test cases. Then the test cases follow.
  • The first line of each test case contains two integers¬†N¬†and¬†M¬†‚ÄĒ the parameters mentioned in the statment.

Maximize Difference CodeChef Solution

Output Format

For each test case, output two integers A and B such that (A, B) is a good pair and the value of |A РB| is maximized.

Constraints

  • 1 \leq T \leq 1000
  • 1 \leq N \leq 10^5
  • N \le M \le 10^9
  • Sum of¬†N¬†over all test cases does not exceed¬†2 \cdot 10^5

Sample 1:

Input

Output

3
5 6
2 8
10 89
6 6
8 2
11 88

Explanation:

Maximize Difference CodeChef Solution

Test case 1: (5, 5) and (6, 6) are the only good pairs and for both of them the value of |A РB| is 0.

Test case 2: (6, 8), (8, 6), (2, 8), (8, 2), (4, 6), (6, 4), (2, 6), (6, 2), (2, 4), (4, 2) and (2, 2) are the good pairs out of which |A РB| is maximum for (2, 8) and (8, 2).

SOLUTION

Maximize Difference CodeChef Solution

SOLUTION

Maximize Difference CodeChef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

4 thoughts on “Maximize Difference CodeChef Solution

Leave a Reply

Your email address will not be published.