We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e0b9bd8 + 5ccaf53 commit dc3467aCopy full SHA for dc3467a
1 file changed
Problems/Mathematics/Day-01/sol/Apoorv012/q1.cpp
@@ -0,0 +1,38 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+
4
+using ll = long long;
5
+const ll MOD = 998244353;
6
7
+void solve() {
8
+ int a, b, c;
9
+ cin >> a >> b >> c;
10
11
+ int diff = abs(a-b);
12
+ if (a > 2*diff || b > 2*diff || c > 2*diff) {
13
+ cout << -1 << endl;
14
+ return;
15
+ }
16
17
+ int ans = c + diff;
18
+ if (ans > 2*diff) {
19
+ ans -= 2*diff;
20
21
22
+ cout << ans << endl;
23
24
+}
25
26
+int main() {
27
+ ios::sync_with_stdio(false);
28
+ cin.tie(nullptr);
29
30
+ int t = 1;
31
+ cin >> t;
32
33
+ while (t--) {
34
+ solve();
35
36
37
+ return 0;
38
0 commit comments