Tests without penalty
Practice
3.6 (20 votes)
Basic math
Observation
Mathematics
C++
Mathematics
Mathematics
Problem
66% Success 3113 Attempts 10 Points 5s Time Limit 256MB Memory 1024 KB Max Code

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
\(1 \le Q \le 10^5\\ 1 \le L\le 10^{12}\\ 1 \le C\le10^{12}\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
1 votes
Tags:
Very-Easy
Points:10
17 votes
Tags:
MathematicsBasic MathMath
Points:10
1 votes
Tags:
Basic MathAlgorithmsMath