File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # PROBLEM STATEMENT :
2+
3+ There are ** n people** standing in a circle. They are numbered from ** 1 to n** in a clockwise order. The circle is ** even** (i.e. * n* is even).
4+
5+ Each person is looking at the person standing exactly opposite him in the circle.
6+
7+ You are given three ** distinct** integers ** a** , ** b** , and ** c** . It is known that person ** a** is looking at person ** b** .
8+
9+ Determine the number of the person that person ** c** is looking at.
10+ If there are ** multiple answers** , print ** any** of them.
11+ If there is ** no answer** , print ** -1** .
12+
13+ ---
14+
15+ ## Input
16+
17+ The first line contains a single integer ** t**
18+ (** 1 ≤ t ≤ 10⁴** ) — the number of test cases.
19+
20+ Each of the following ** t** lines contains three distinct integers ** a** , ** b** , and ** c**
21+ (** 1 ≤ a, b, c ≤ 10⁸** ).
22+
23+ ---
24+
25+ ## Output
26+
27+ For each test case, print the answer —
28+ the number of the person that person ** c** is looking at,
29+ or ** -1** if the answer does not exist.
30+
31+ ---
32+
33+ ## Example
34+
35+ ### Input
36+ ```
37+ 7
38+ 6 2 4
39+ 2 3 1
40+ 2 4 10
41+ 5 3 4
42+ 1 3 2
43+ 2 5 4
44+ 4 3 2
45+ ```
46+
47+
48+ ### Output
49+ ```
50+ 8
51+ -1
52+ -1
53+ -1
54+ 4
55+ 1
56+ -1
57+ ```
58+ The problem statement is given just in case the codeforces server lags.<br >
59+ Submit your solution in the link given below and send a PR upon receiving AC.
60+
61+ [ PROBLEM LINK] ( https://codeforces.com/problemset/problem/1560/B )
62+
63+
You can’t perform that action at this time.
0 commit comments