We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 3cec148 + f130657 commit ca40ec2Copy full SHA for ca40ec2
1 file changed
Problems/Mathematics/Day-01/sol/Avaneesh Verma/solution001.py
@@ -0,0 +1,27 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+
4
+int main() {
5
+ int t;
6
+ cin >> t;
7
+ while (t--) {
8
+ int a, b, c;
9
+ cin >> a >> b >> c;
10
11
+ int diff = abs(a - b);
12
+ int n = 2 * diff;
13
+ if (diff == 0 || a > n || b > n || c > n) {
14
+ cout << -1 << '\n';
15
+ continue;
16
+ }
17
+ int half = n / 2;
18
+ int d;
19
+ if (c + half <= n)
20
+ d = c + half;
21
+ else
22
+ d = c - half;
23
+ cout << d << '\n';
24
25
26
+ return 0;
27
+}
0 commit comments