Skip to content

Commit bf4428f

Browse files
Q1 day1 solved
1 parent 0e00f83 commit bf4428f

7 files changed

Lines changed: 43 additions & 0 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

Problems/.DS_Store

0 Bytes
Binary file not shown.

Problems/Mathematics/.DS_Store

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
8 KB
Binary file not shown.
6 KB
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*We have:
2+
3+
An even number of people n standing in a circle, numbered 1 to n clockwise.
4+
5+
Each person looks directly opposite in the circle.
6+
7+
You are given three numbers: a, b, c.
8+
9+
a is looking at b.
10+
11+
We want to know who c is looking at.
12+
13+
If no circle is possible → return -1.
14+
15+
*/
16+
17+
typedef long long ll;
18+
#include <bits/stdc++.h>
19+
using namespace std;
20+
21+
int main() {
22+
int t;
23+
cin>>t;
24+
while(t--){
25+
ll a, b, c;
26+
cin >> a >> b >> c;
27+
28+
ll diff = abs(a - b);
29+
ll n = 2 * diff;
30+
31+
if (diff==0 || max({a,b,c})> n){
32+
cout << -1 << endl;
33+
} else {
34+
ll d = c + diff;
35+
if (d > n) d -= n;
36+
cout << d << endl;
37+
}
38+
}
39+
return 0;
40+
}
41+
42+
//O(1) per test case
43+
//My SUBMISSION : https://codeforces.com/contest/1560/submission/355307599

0 commit comments

Comments
 (0)