Ninja has been given two baskets of apples containing ‘A’ and ‘B’ apples each. Also, he has been given extra ‘C’ apples separately.
This apple will be gifted to the Ninja’s best buddies; Ninja wants to do some partiality so that the number of apples in the first basket is strictly greater than the number of apples in the second basket.
The ninja can do it using extra ‘C’ apples, he must have to use all the extra apples and transfer them in both the first and second basket.
Your task is to help Ninja by calculating a number of possible arrangements of apples so that the resultant configuration is feasible for Ninja to do the partiality.
EXAMPLE:Input: 'A' = 5, 'B' = 3, 'C' = 4
Output: 3
Here only three possible combinations are:
(7, 5) Transfer 2 apples to the first basket and 2 apples to the second basket.
(9, 3) Transfer 4 apples to the first basket and 0 apples to the second basket.
(8, 4) Transfer 3 apples to the first basket and 1 apple to the second basket.
Only above combinations for (A, B) satisfies the condition that all 'C' apples are used and ('A' > 'B')
The first line will contain integer 'T' denoting the number of test cases. For each test case, there will be a single line containing three integers 'A', 'B', and 'C' only.
Output format :
For each test case, print a single line containing a single integer number of possible arrangements of apples so that the resultant configuration is feasible for Ninja to do the partiality.
Note :
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= 'T' <= 10^5
0 <= 'A', 'B', 'C'<= 10^8
Time Limit : 1 sec
2
10 6 4
2 1 0
4
1
For the first test case, only three possible combinations are:
(11, 9) Transfer 1 apple to the first basket and 3 apples to the second basket.
(12, 8) Transfer 2 apples to the first basket and 2 apples to the second basket.
(14, 6) Transfer 4 apples to the first basket and 0 apples to the second basket.
(13, 7) Transfer 3 apples to the first basket and 1 apple to the second basket.
Only above combinations for (A, B) satisfies the condition for all 'C' are used and ('A' > 'B')
For the second test case only one combination (2, 1) is possible because there are no extra apples.
2
3 5 5
4 10 6
2
0
Can you try to derive the formula for an answer?
Approach:
Algorithm :
O(1)
As all the operations are constant time, the time complexity will be O(1).
O(1)
As we are using the constant extra space, the space complexity will be O(1).