Skip to content

Commit 7618447

Browse files
Add files via upload
1 parent 7824773 commit 7618447

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

  • Problems/Mathematics/Day-01/sol/Aiyaan_Mahajan
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
DAY 1
3+
Q1 Who's Opposite?
4+
.*/
5+
6+
typedef long long ll;
7+
#include <bits/stdc++.h>
8+
using namespace std;
9+
10+
int main() {
11+
int t;
12+
cin>>t;
13+
while(t--){
14+
ll a, b, c;
15+
cin >> a >> b >> c;
16+
17+
ll diff = abs(a - b);
18+
ll n = 2 * diff;
19+
20+
if (diff==0 || max({a,b,c})> n){
21+
cout << -1 << endl;
22+
} else {
23+
ll d = c + diff;
24+
if (d > n) d -= n;
25+
cout << d << endl;
26+
}
27+
}
28+
return 0;
29+
}
30+
/*
31+
My submission : https://codeforces.com/contest/1560/submission/355307599
32+
*/

0 commit comments

Comments
 (0)