File tree Expand file tree Collapse file tree
Problems/Mathematics/Day-01/sol 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 umpp (i, j ) unordered_map<i, j, custom_hash>
5+ #define mpp (i, j ) map<i, j>
6+ #define int long long
7+ #define ll long long
8+ #define vi vector<int >
9+ #define pii pair<int , int >
10+ #define vpii vector<pair<int ,int >>
11+ #define pb push_back
12+ #define pob pop_back
13+ #define sz (x ) ((int )(x).size())
14+ #define all (v ) v.begin(), v.end()
15+ #define F first
16+ #define S second
17+ #define sortall (x ) sort(all(x))
18+ #define tr (it, a ) for (auto it = a.begin(); it != a.end(); it++)
19+ #define forx (x, n ) for (int x = 0 ; x < (n); x++)
20+ #define PI 3.1415926535897932384626
21+ const int mod = 1e9 + 7 ;
22+
23+ void solve () {
24+ int a,b,c; cin >> a>>b>>c;
25+ int diff = abs (a - b);
26+ int t = 2 * diff;
27+ if (a>t || b>t||c>t){
28+ cout << -1 << endl;
29+ }
30+ else {
31+ int a1 = c - diff;
32+ int a2 = c + diff;
33+ if (a1>=1 && a1<=t){
34+ cout << a1 << endl;
35+ return ;
36+ }
37+ cout << a2 << endl;
38+ }
39+ }
40+
41+ signed main () {
42+ ios_base::sync_with_stdio (0 );
43+ cin.tie (0 );
44+ cout.tie (0 );
45+ srand (chrono::high_resolution_clock::now ().time_since_epoch ().count ());
46+ int t = 1 ;
47+ cin >> t;
48+ while (t--) solve ();
49+ return 0 ;
50+ }
You can’t perform that action at this time.
0 commit comments