We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 98005d0 commit fd43652Copy full SHA for fd43652
2 files changed
Problems/Mathematics/Day-01/sol/Lavay Garg/Solution1.cpp
@@ -0,0 +1,24 @@
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 || max({a, b, c}) > N) {
14
+ cout << -1 << '\n';
15
+ continue;
16
+ }
17
18
+ if (c > N / 2) {
19
+ cout << c - N / 2 << '\n';
20
+ } else {
21
+ cout << c + N / 2 << '\n';
22
23
24
+}
Problems/Mathematics/Day-01/sol/Lavay Garg/run
16.9 KB
0 commit comments