We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents fc1fc6f + 66b1e37 commit 8581b71Copy full SHA for 8581b71
1 file changed
Problems/Mathematics/Day-01/sol/Nitin Kumar/ques1.cpp
@@ -0,0 +1,30 @@
1
+/* Submission link: https://codeforces.com/contest/1560/submission/355246381
2
+
3
+Time Complexity : O(1);
4
5
+*/
6
7
+#include<bits/stdc++.h>
8
+using namespace std;
9
+int main(){
10
+ int t;
11
+ cin>>t;
12
+ while(t--){
13
+ long long int a,b,c;
14
+ cin>>a>>b>>c;
15
+ long long int maxval=2* abs(a-b);
16
+ if(maxval>=a&&maxval>=b&&maxval>=c){
17
+ long long int temp=2*abs(a-b);
18
+ long long int ans=abs(a-b)+c;
19
+ if(ans%temp==0){
20
+ cout<<temp<<endl;
21
+ }
22
+ else{
23
+ cout<<ans%temp<<endl;
24
25
26
27
+ cout<<"-1\n";
28
29
30
+}
0 commit comments