-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2009A_Mininmize.cpp
More file actions
45 lines (41 loc) · 1.13 KB
/
2009A_Mininmize.cpp
File metadata and controls
45 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* A. Minimize!
time limit per test 1 second
memory limit per test 256 megabytes
You are given two integers a and b (a≤b). Over all possible integer values of c (a≤c≤b), find the minimum value of (c−a)+(b−c).
Input:
The first line contains t (1≤t≤55) — the number of test cases.
Each test case contains two integers a and b (1≤a≤b≤10).
Output
For each test case, output the minimum possible value of (c−a)+(b−c) on a new line.
Example
Input:
3
1 2
3 10
5 5
Output:
1
7
0
Note
In the first test case, you can choose c=1 and obtain an answer of (1−1)+(2−1)=1. It can be shown this is the minimum value possible.
In the second test case, you can choose c=6 and obtain an answer of (6−3)+(10−6)=7. It can be shown this is the minimum value possible.
*/
#include<bits/stdc++.h>
using namespace std;
int t,n,i,j;
void solve(){
int a , b;
cin>>a>>b;
int c = b-1;
int x = (c-a)+(b-c);
cout<<x<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
while(t--){
solve();
}
}