In a survey, it was found that out of the people living in the city are currently infected. It has been observed that the only way for a person to get infected is if he comes in contact with an already infected person, and both of them are NOT wearing a mask.
The mayor of the city wants to make a new Mask Policy and find out the minimum number of people that will be required to wear a mask to avoid the further spread of the virus. Help the mayor in finding this number.
Note: The only aim of the mayor is to stop virus spread, not to mask every infected person.
Input Format
- The first line contains - number of test cases. Then the test cases follow.
- The first and only line of each test case contains two integers and - the total number of people living in the city and the number of people already affected by the virus respectively.
Output Format
For each test case, output the minimum number of people that will be required to wear a mask so as to curb the virus spread.
Constraints
Sample Input 1
3
2 1
3 2
3 1
Sample Output 1
1
1
1
Explanation
Test Case #1: There is infected person and uninfected person. We can ask any of them to wear a mask, and no more infections will occur. Hence the answer is .
Test Case #2: There are infected people and uninfected person. We can ask the uninfected person to wear a mask, and no more infections will occur. Hence the answer is .
Test Case #3: There is infected person and uninfected people. We can ask the single infected person to wear a mask, and no more infections will occur. Hence the answer is .
Solution
No comments:
Post a Comment