Tests without penalty

3.6

20 votes
Basic Math, Observation, Mathematics, C++, Mathematics, Mathematics
Problem

You are attempting a test in which there is no punishment for wrong submissions and time constraints. There can be many numbers of participants on the same rank. The candidates who have the same score are on the same rank. The next rank is determined on the basis of the number of candidates who have secured the previous rank. 

You are given the last rank and number of candidates who have secured the last rank. For example, if there are five candidates in the contest and their respective scores are 100, 100, 90, 90, and 80. The ranks of these candidates are 1, 1, 3, 3, and 5 respectively. You know 5 and 1 that is the last rank and the number of participants who have secured the last rank. You are required to determine the total number of participants in the contest.

Input format

  • First line: A single integer Q denoting the number of queries
  • Next Q Lines: Two integers L and C denoting the last rank in the contest and number of participants who have secured the last rank

Output format

For each query, print an integer N denoting the total number of contestants in the contest.

Constraints
1Q1051L10121C1012

Sample Input
1
5 1
Sample Output
5
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Please refer to the problem statement for sample explanation.

Editor Image

?