Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define e endl
- #define r0 return 0
- #define co continue
- using namespace std;
- int f ( ll aa , ll bb , ll cc ) {
- vector <ll> arr;
- arr.push_back(aa);
- arr.push_back(bb);
- arr.push_back(cc);
- sort ( arr.begin() , arr.end() );
- if ( arr[2] - arr[0] == 0 || arr[2] - arr[0] == 1 || arr[2] - arr[0] == 2 ) {
- return 0 ;
- }
- else {
- //if ( arr[1] == arr[2] ) {
- // arr[1] -- ;
- // arr[2] -- ;
- // arr[0] ++ ;
- arr[2] -- ;
- arr[1] -- ;
- arr[0] ++ ;
- return ( arr[2] - arr[0] ) + ( arr[1] - arr[0] ) + ( arr[2] - arr[1]);
- //}
- //else {
- // arr[]
- //}
- }
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int t ;
- cin >> t ;
- while ( t -- ) {
- ll a , b , c ;
- cin >> a >> b >> c ;
- cout << f ( a , b , c ) << e ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment