Skip to content

Commit 8581b71

Browse files
authored
Merge pull request #195 from Nitinkr03/main
Issue: #35
2 parents fc1fc6f + 66b1e37 commit 8581b71

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • Problems/Mathematics/Day-01/sol/Nitin Kumar
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
else{
27+
cout<<"-1\n";
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)