Skip to content

Commit e81b589

Browse files
committed
Added 1560B - Who's Opposite?.cpp
1 parent 8871ee5 commit e81b589

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

1560B - Who's Opposite.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
5+
#define ll long long
6+
#define pb push_back
7+
#define ff first
8+
#define ss second
9+
#define mp make_pair
10+
11+
// Code Written By: Vikash Patel
12+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
13+
14+
int solve()
15+
{
16+
int a,b,c;
17+
cin>>a>>b>>c;
18+
int d = abs(a-b);
19+
int tp = d*2;
20+
if(a>tp || b>tp || c>tp || d == 1 || tp%2)
21+
return -1;
22+
if(c+d>=1 && c+d<=tp)
23+
return c+d;
24+
if(c-d>=1 && c-d<=tp)
25+
return c-d;
26+
return -1;
27+
}
28+
int main()
29+
{
30+
ios_base::sync_with_stdio(0);
31+
cin.tie(0);
32+
cout.tie(0);
33+
34+
// #ifndef ONLINE_JUDGE
35+
// freopen("input.txt", "r", stdin);
36+
// freopen("/Users/vikash/Desktop/output.txt", "w", stdout);
37+
// #endif
38+
39+
int t;
40+
cin>>t;
41+
while(t--)
42+
{
43+
cout<<solve()<<endl;
44+
}
45+
return 0;
46+
}
47+

0 commit comments

Comments
 (0)