File tree Expand file tree Collapse file tree
Problems/Mathematics/Day-01/sol/Hardik Singh Rana Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ #define ll long long
5+ #define pb push_back
6+ #define f (i,a,b ) for (ll i = a; i < b; i++)
7+ #define fb (i,a,b ) for (ll i = a; i >= b; i--)
8+ #define all (v ) (v).begin(), (v).end()
9+
10+ typedef vector<int > vi;
11+ typedef vector<ll> vl;
12+ typedef pair<int ,int > pii;
13+ typedef pair<ll,ll> pll;
14+
15+ #define fastio ios::sync_with_stdio (false ); cin.tie(NULL );
16+
17+ ll binexp (ll a, ll b) {
18+ ll res = 1 ;
19+ while (b > 0 ) {
20+ if (b & 1 ) res = res * a;
21+ a = a * a;
22+ b >>= 1 ;
23+ }
24+ return res;
25+ }
26+
27+ void solve () {
28+ int a,b,c;
29+ cin>>a>>b>>c;
30+ if (c>2 *abs (a-b) or a>2 *abs (a-b) or b>2 *(abs (a-b))){
31+ cout<<-1 <<endl;
32+ }
33+ else {
34+ if (c>abs (a-b)) cout<<c-abs (a-b)<<endl;
35+ else cout<<c+abs (a-b)<<endl;
36+ }
37+ }
38+
39+ int main () {
40+ fastio;
41+ int t = 1 ;
42+ cin >> t;
43+ while (t--) solve ();
44+ }
You can’t perform that action at this time.
0 commit comments