-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy path1272A.cpp
44 lines (39 loc) · 933 Bytes
/
1272A.cpp
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
#include<bits/stdc .h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a, a 3);
if(a[0] == a[1] && a[2] != a[1]){
if(a[2] - a[1] > 1){
a[2] -= 1;
}
a[0] = a[0] 1;
a[1] = a[1] 1;
}
else if(a[2] == a[1] && a[0] != a[1]){
if(a[1] - a[0] > 1){
a[0] = 1;
}
a[2] = a[2] - 1;
a[1] = a[1] - 1;
}
else if(a[2] != a[1] && a[0] != a[1]){
a[0] = 1;
a[2] -= 1;
}
int dista = (a[0] - a[1] >= 0) ? (a[0] - a[1]) : (a[1] - a[0]);
int distb = (a[1] - a[2] >= 0) ? (a[1] - a[2]) : (a[2] - a[1]);
int distc = (a[0] - a[2] >= 0) ? (a[0] - a[2]) : (a[2] - a[0]);
cout<<(dista distb distc)<<endl;
}
}