All submissions for this problem are available.
Read problems statements in mandarin chinese, russian and vietnamese as well.
On the occasion of the birthday, Chef bought a large circular cake and decorated it with k candles placed equally spaced around the circumference of the cake, i.e. the lengths of the arcs that connect any two adjacent candles are equal.
Chef enumerated the candles from 1 to k in clockwise manner. He then chose two candles, say A and B and lit them up. Now, he left the kitchen and decided to come back in some time with friends to celebrate the birthday.
Meanwhile Chef's little brother came to the kitchen and saw the cake. He wants to light up one of the not lit candles C such that angle ACB is an obtuse angle. He believes that such a pattern of lit candles will be auspicious. Can you find out how many candles C he can light up?
The first line contains a single integer T, the number of test cases. Each test case is described by a single line containing three space-separated integers k, A, B.
For each test case, output a single line containing one integer: the answer for the test case.
- 1 ≤ T ≤ 105
- 3 ≤ k ≤ 109
- 1 ≤ A, B ≤ k
- A ≠ B
Input: 3 6 1 3 6 1 4 10 1 5 Output: 1 0 3
Example case 1. Only candle with number 2 is suitable.
Example case 2. No matter how we choose C the angle would have 90 degrees.
Example case 3. Candles with numbers 2,3,4 are suitable.
|Tags||cook85, easy, math, melnik|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.