Round It

0

0 votes
Problem

To round an integer a, it is customary to round to some multiple of a power of 10, and you will round it accordingly. This time, rules have changed. Given an int n and an int b, round n to the nearest value which is a multiple of b. If n is exactly halfway between two multiples of b, print the larger value.

INPUT

First line of input gives T, the number of test cases. T lines follow, each line contains n and b.

OUTPUT

For every test case, round n to the nearest value which is a multiple of b.

CONSTRAINTS

  • n will be between 1 and 1000000, inclusive.
  • b will be between 2 and 500, inclusive.
  • 1<= T <= 50
Time Limit: 1
Memory Limit: 1
Source Limit:
Explanation

CASE 1: We round up because 5 is an equal distance between 0 and 10.

CASE 2: 100 is closer to 99 than 102.

Editor Image

?