CodechefJul 25, 2025

Reach the Target

Hazrat Ali

Codechef

Team B is batting second and got a target of X runs. Currently, team B has scored Y runs. Determine how many more runs Team B should score to win the match.

Note: The target score in cricket matches is one more than the number of runs scored by the team that batted first.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two space-separated integers X and Y, the target for team BB and the current score of team B respectively.

Output Format

For each test case, output how many more runs team B should score to win the match.

Constraints

  • 1≤T≤10
  • 50≤Y<X≤200

Sample 1:

Input
4
200 50
100 99
130 97
53 51
Output
 
150
1
33
2

Soltion
#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;  
    while (t--) {
        int a, b;
        cin >> a >> b;
        cout << (a - b) << endl;
    }
    return 0;
}



Comments