We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ff01ed5 + f34417c commit 067a424Copy full SHA for 067a424
1 file changed
Problems/Mathematics/Day-01/sol/Kunwar Gaba/Solution1.cpp
@@ -0,0 +1,31 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+#define int long long int
4
+#define double long double
5
+#define endl '\n'
6
+void resolve() {
7
+ int a,b,c,d=0;
8
+ cin>>a>>b>>c;
9
+ int n = 2*abs(b-a);
10
+ if(b>n || c>n || a>n)
11
+ d = -1;
12
+ else
13
+ {
14
+ if(c<=(n/2))
15
+ d = c + n/2;
16
17
+ d = c - n/2;
18
+
19
+ if(d==a || d==b || d>n || d<1)
20
+ d=-1;
21
+ }
22
+ cout<<d<<endl;
23
+}
24
+int32_t main() {
25
+ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
26
+ int t;
27
+ cin >> t;
28
+ while(t--)
29
+ resolve();
30
+ return 0;
31
0 commit comments