Multiple of X closest to N
Submissions: 753   Accuracy:

23.79%

  Difficulty: Basic   Marks: 1

Given two numbers N and X, you need to write a program that will output the smallest value of (X*K) which is closest to N. Where K is any positive number greater than zero.

Input:
The first line of input contains a single integer T which denotes the number of test cases. Then T test cases follows. The only line of each test case contains two space separated integers N and X.

Output:
For each test print the closest value of (X*K) in a new line, where is any positive number greater than zero.
Note: If there are two closest elements then print the bigger one.

Constraints:
1<=T<=100
1<=X<=1000
1<=N<=1000

Example:
Input:
2

9 2
2855 13
Output:

10
2860

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harsh Agarwal
Author: harsh.agarwal0


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.