We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents f92e2bb + 6fd56b9 commit a0dcbd0Copy full SHA for a0dcbd0
1 file changed
Problems/Mathematics/Day-01/sol1/BEESA-MANISH/Solution1.cpp
@@ -0,0 +1,31 @@
1
+
2
+//Time: O(t)
3
4
+//Space: O(1)
5
6
+#include <bits/stdc++.h>
7
+using namespace std;
8
+int main(){
9
+ int t;
10
+ cin >> t;
11
+while(t--){
12
+ long long a, b, c;
13
+ cin >> a >> b >> c;
14
+long long dist=llabs(a - b);
15
+long long n=2*dist;
16
+if(dist==0 || c>n){
17
+cout << -1 << '\n';
18
+continue;
19
+}
20
+long long half=n/2;
21
+if(c+half<=n){
22
+ cout << c+half << '\n';
23
24
+else{
25
+ cout << c-half << '\n';
26
27
28
29
+ return 0;
30
31
0 commit comments