There are N students in a class. Recently, an exam on Advanced Algorithms was conducted with maximum score M and minimum score 0. The average score of the class was found out to be exactly X.  

Given that a student having score strictly greater than the average receives an A grade, find the maximum number of students that can receive an A grade.

------ Input Format ------ 

- First line will contain T, number of test cases. Then the test cases follow.
- The only line of each test case consists of three integers N, M, X - the number of students, the maximum score and the average score respectively.

------ Output Format ------ 

For each test case, output in a single line, the maximum number of students who can receive A grade.

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$2 ≤ N ≤ 10^{7}$
$1 ≤ X ≤ M ≤ 100$

----- Sample Input 1 ------ 
4
2 100 50
3 100 50
5 40 40
10 50 49

----- Sample Output 1 ------ 
1
2
0
9

----- explanation 1 ------ 
Test case $1$: There are $2$ students in the class. One of the possible values of scores is $[99, 1]$. Here, the average score is $\frac{99+1}{2} = \frac{100}{2} = 50$. Only the first student receives an A grade. It can be shown that the maximum number of students receiving an A grade is not more than $1$.

Test case $2$: There are $3$ students in the class. One of the possible values of the scores is $[60, 20, 70]$. Here, the average score is $\frac{60+20+70}{3} = \frac{150}{3} = 50$. The students receiving an A grade are students $1$ and $3$. It can be shown that the maximum number of students receiving an A grade is not more than $2$.

Test case $3$: There are $5$ students in the class. The average score and the maximum score is $40$. Thus, the scores of all the students is $40$. Since the score of all the students is equal to the average, none of them receive an A grade.

Test case $4$: It can be shown that the maximum number of students receiving an A grade does not exceed $9$.

Source: codechef | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input())
for tc in range(t):
	(n, m, x) = map(int, input().split())
	if m == x:
		print('0')
	else:
		print(n * x // (x + 1))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if b == c:
		print('0')
	else:
		print(int(c * a / (c + 1)))


for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	if m == x:
		print(0)
	else:
		print(x * n // (x + 1))


for _ in range(int(input())):
	(n, m, x) = map(int, input().strip().split())
	if x == m:
		print(0)
	else:
		print(int(x * n / (x + 1)))


t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	nm = n * m
	nx = n * x
	if nx < nm:
		ct = nx // (x + 1)
		print(ct)
	else:
		print(0)


from math import ceil
for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	if x >= m:
		print(0)
		continue
	a = n * x
	print(a // (x + 1))


try:
	for _ in range(int(input())):
		(N, M, X) = map(int, input().split())
		c = N * X
		if M == X:
			print(0)
		else:
			print(c // (X + 1))
except:
	pass


t = int(input())
for t in range(t):
	(n, m, x) = [int(i) for i in input().split()]
	if m == x:
		print(0)
	else:
		res = n * x
		print(res // (x + 1))


t = int(input())
for ni in range(t):
	(n, m, x) = map(int, input().split())
	s = n * x
	c = s // (x + 1)
	if m != x:
		print(c)
	else:
		print(0)


for _ in range(int(input())):
	(n, m, x) = list(map(int, input().split()))
	tot = n * x
	s = tot // (x + 1)
	if m == x:
		print(0)
	else:
		print(s)


t = int(input())
for i in range(t):
	(n, m, x) = map(int, input().split())
	c = 0
	if m == x:
		print(0)
	else:
		temp = n * x
		print(temp // (x + 1))


for _ in range(int(input())):
	(N, M, X) = map(int, input().split())
	T = N * X
	if M == X:
		print(0)
	else:
		print(T // (X + 1))


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	sum1 = n * x
	j = x + 1
	if m == x:
		print(0)
	else:
		print(sum1 // j)


a = int(input(''))
for i in range(a):
	(N, M, X) = [int(x) for x in input('').split()]
	u = N * X
	j = X + 1
	if M == X:
		print(0)
	else:
		print(u // j)


for tc in range(int(input())):
	(n, m, x) = map(int, input().split())
	sumofscores = x * n
	oneover = x + 1
	if x < m:
		print(sumofscores // oneover)
	else:
		print(0)


n = int(input())
for i in range(n):
	(t, m, x) = list(map(int, input().split()))
	if m == 0 or m == x:
		print(0)
	else:
		print(t * x // (x + 1))


import math
t = int(input())
for i in range(t):
	(n, m, x) = map(int, input().split())
	if x == m or m == 0:
		print(0)
	else:
		print(n - math.ceil(n / (x + 1)))


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	if x == m:
		print(0)
	elif x < m:
		print(n * x // (x + 1))


for a in range(int(input())):
	(N, M, X) = map(int, input().split())
	if M == X:
		print(0)
	else:
		print(N * X // (X + 1))


t = int(input())
for _ in range(0, t):
	(n, m, x) = map(int, input().split())
	if x < m:
		k = n * x // (x + 1)
		print(k)
	else:
		print(0)


import math
t = int(input())
for i in range(0, t):
	ans = 0
	(a, b, c) = map(int, input().split())
	if b == c or b < c:
		print(0)
	else:
		sum_of = c * a
		ans = int(sum_of / (c + 1))
		print(ans)


t = input()
for c in range(0, int(t)):
	(n, m, x) = map(int, input().split())
	ans = n * x
	r = x + 1
	if r > m:
		print('0')
	else:
		print(int(ans / r))


T = int(input())
for tc in range(T):
	(N, M, X) = list(map(int, input().split(' ')))
	ts = X * N
	if M == X:
		print(0)
	else:
		print(ts // (X + 1))


t = int(input())
while t:
	t -= 1
	(n, m, x) = map(int, input().split(' '))
	print(n * x // (x + 1) if m != x else '0')


n = int(input())
while n:
	n -= 1
	inp = list(map(int, input().split()))
	if inp[1] == inp[2]:
		count = 0
	else:
		count = int(inp[2] * inp[0] / (inp[2] + 1))
	print(count)


for t in range(int(input())):
	(n, m, x) = map(int, input().split())
	ts = x * n
	if m != x:
		res = int(ts / (x + 1))
	else:
		res = 0
	print(res)


import math
tests = int(input())
ans = 0
for i in range(tests):
	(n, m, x) = map(int, input().split())
	if m <= x:
		print(0)
	else:
		required = math.ceil(n / (x + 1))
		print(n - required)


for i in range(int(input())):
	(n, m, a) = map(int, input().split())
	ans = a + 1
	if m == a:
		print(0)
	else:
		print(n * a // ans)


for _ in range(int(input())):
	a = list(map(int, input().split(' ')))
	n = a[0]
	m = a[1]
	x = a[2]
	if m == x:
		print(0)
	elif m > x:
		print(n * x // (x + 1))


from bisect import bisect_left
from re import sub
import re
from typing import DefaultDict
import math
from collections import defaultdict
from math import sqrt
import collections
from sys import maxsize
from itertools import combinations_with_replacement
import sys
import copy

def sieve_erasthones(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	for p in range(n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def calculate(p, q):
	mod = 998244353
	expo = 0
	expo = mod - 2
	while expo:
		if expo & 1:
			p = p * q % mod
		q = q * q % mod
		expo >>= 1
	return p

def count_factors(n):
	i = 1
	c = 0
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				c += 1
			else:
				c += 2
		i += 1
	return c

def ncr_modulo(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def isprime(n):
	prime_flag = 0
	if n > 1:
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				prime_flag = 1
				break
		if prime_flag == 0:
			return True
		else:
			return False
	else:
		return True

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def dict_ele_count(l):
	d = DefaultDict(lambda : 0)
	for ele in l:
		d[ele] += 1
	return d

def max_in_dict(d):
	maxi = 0
	for ele in d:
		if d[ele] > maxi:
			maxi = d[ele]
	return maxi

def element_count(s):
	l = []
	k = s[0]
	c = 0
	for ele in s:
		if ele == k:
			c += 1
		else:
			l.append([k, c])
			k = ele
			c = 1
	l.append([k, c])
	return l

def modular_exponentiation(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 != 0:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def number_of_primefactor(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(n)
	return len(set(l))

def twosum(a, n, x):
	rem = []
	for i in range(x):
		rem.append(0)
	for i in range(n):
		if a[i] < x:
			rem[a[i] % x] += 1
	for i in range(1, x // 2):
		if rem[i] > 0 and rem[x - i] > 0:
			return True
	if i >= x // 2:
		if x % 2 == 0:
			if rem[x // 2] > 1:
				return True
			else:
				return False
		elif rem[x // 2] > 0 and rem[x - x // 2] > 0:
			return True
		else:
			return False

def divSum(num):
	result = 0
	i = 2
	while i <= math.sqrt(num):
		if num % i == 0:
			if i == num / i:
				result = result + i
			else:
				result = result + (i + num / i)
		i = i + 1
	return result + 1 + num

def subsequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def primeFactors(n):
	d = defaultdict(lambda : 0)
	while n % 2 == 0:
		d[2] += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			d[int(i)] += 1
			n = n / i
	if n > 2:
		d[int(n)] += 1
	return d

def calc(s):
	ans = 0
	for ele in s:
		ans += ord(ele) - 96
	return ans

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def modDivide(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	return inv * a % m

def count(n):
	ans = 0
	while n:
		ans += n % 10
		n //= 10
	return ans

def solve():
	(n, m, x) = map(int, input().split())
	if m == x:
		print(0)
	else:
		print(n * x // (x + 1))
for _ in range(int(input())):
	solve()


def solve():
	[x, y, z] = list(map(int, input().split()))
	if y == z:
		print(0)
		return
	m = z * x // (z + 1)
	print(m)
n = int(input())
for i in range(n):
	solve()


T = int(input())

def ceil(A):
	if A == int(A):
		return int(A)
	else:
		return int(A) + 1
for _ in range(T):
	(N, M, X) = map(int, input().split())
	if M == X:
		print('0')
	else:
		A = ceil(N / (X + 1))
		print(N - A)


T = int(input())
for _ in range(T):
	(n, m, a) = map(int, input().split())
	if a + 1 > m:
		print(0)
	else:
		print(a * n // (a + 1))


while True:
	try:
		for _ in range(int(input())):
			(n, m, x) = map(int, input().split())
			if m == x:
				print(0)
			else:
				t = x * n
				print(t // (x + 1))
	except:
		break


def maxA(n, m, x):
	if x == m:
		return 0
	return x * n // (x + 1)
t = int(input())
for i in range(t):
	(n, m, x) = map(int, input().split())
	print(maxA(n, m, x))


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	if c == b:
		print('0')
	else:
		k = a * c // (c + 1)
		print(k)