We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent edabfd2 commit 60f7795Copy full SHA for 60f7795
1 file changed
Problems/Mathematics/Day-01/sol/Paarth_arora/solution1.cpp
@@ -0,0 +1,25 @@
1
+//https://codeforces.com/submissions/paarth_arora link for submissions
2
+#include <bits/stdc++.h>
3
+using namespace std;
4
+int main() {
5
+ int t;
6
+ cin >> t;
7
+ while(t--) {
8
+ long long a,b,c;
9
+ cin>>a>>b>>c;
10
+ if((abs(b-a))*2<max(a,max(b,c))){
11
+ cout << -1 <<'\n';
12
+ }
13
+
14
+ else if(c+(abs(b-a))>(abs(b-a)*2)){
15
+ cout<<(c+(abs(b-a)))%(abs(b-a)*2)<<endl;
16
17
+ else{
18
+ cout<<c+(abs(b-a))<<endl;
19
20
21
22
+ return 0;
23
+}
24
+//time complexity-o(1)
25
+//space complexity-o(1)
0 commit comments