Skip to content

Commit 018b0fc

Browse files
committed
Solved Mathematics/Day-01/q001.md
1 parent fb643f5 commit 018b0fc

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
void solve(){
5+
int a,b,c;
6+
cin>>a>>b>>c;
7+
int n=2*abs(a-b);
8+
9+
int opp=c+n/2;
10+
if(c>n||b>n||a>n){
11+
cout<<-1<<endl;
12+
return;
13+
}
14+
if(opp>n)opp=opp-n;
15+
16+
cout<<opp<<endl;
17+
}
18+
19+
int main(){
20+
int t;
21+
cin>>t;
22+
while(t--)solve();
23+
}

0 commit comments

Comments
 (0)