Read problems statements in [Hindi], [Mandarin Chinese], [Vietnamese], and [Bengali] as well.

You are given the height $H$ (in metres) and mass $M$ (in kilograms) of Chef. The Body Mass Index (BMI) of a person is computed as $\frac{M}{H^{2}}$.

Report the category into which Chef falls, based on his BMI:

Category 1: Underweight if BMI $≤ 18$
Category 2: Normal weight if BMI $\in \{19$, $20$,$\ldots$, $24\}$
Category 3: Overweight if BMI $\in \{25$, $26$,$\ldots$, $29\}$
Category 4: Obesity if BMI $≥ 30$

------ Input: ------

The first line of input will contain an integer, $T$, which denotes the number of testcases. Then the testcases follow. 
Each testcase contains a single line of input, with two space separated integers, $M, H$, which denote the mass and height of Chef respectively. 

------ Output: ------
For each testcase, output in a single line, $1, 2, 3$ or $4$, based on the category in which Chef falls.

------ Constraints  ------
$1 ≤ T ≤ 2*10^{4}$
$1 ≤ M ≤ 10^{4}$
$1 ≤ H ≤ 10^{2}$
Its guaranteed that $H^{2}$ divides $M$.

----- Sample Input 1 ------ 
3
72 2
80 2
120 2
----- Sample Output 1 ------ 
1
2
4
----- explanation 1 ------ 
Case 1: Since $\frac{M}{H^{2}} = \frac{72}{2^{2}} = 18$, therefore person falls in category $1$.

Case 2: Since $\frac{M}{H^{2}} = \frac{80}{2^{2}} = 20$, therefore person falls in category $2$.

Case 3: Since $\frac{M}{H^{2}} = \frac{120}{2^{2}} = 30$, therefore person falls in category $4$.

Difficulty: EASY
Tags: Mathematics

Ad-hoc

Starter code:

Solutions:
for i in range(int(input())):
	(m, h) = map(int, input().split())
	BMI = m // h ** 2
	if BMI <= 18:
		print(1)
	elif BMI >= 19 and BMI <= 24:
		print(2)
	elif BMI >= 25 and BMI <= 29:
		print(3)
	else:
		print(4)


for t in range(int(input())):
	(m, h) = map(int, input().split())
	bmi = m / h ** 2
	if bmi <= 18:
		print(1)
	elif bmi in {19, 20, 21, 22, 23, 24}:
		print(2)
	elif bmi in {25, 26, 27, 28, 29}:
		print(3)
	elif bmi >= 30:
		print(4)


t = int(input())
for i in range(t):
	(m, h) = map(int, input().split())
	b = m // (h * h)
	if b <= 18:
		print('1')
	elif 19 <= b <= 24:
		print('2')
	elif 25 <= b <= 29:
		print('3')
	elif b >= 30:
		print('4')


import math
for t in range(int(input())):
	(m, h) = map(int, input().split())
	a = math.pow(h, 2)
	bmi = m / a
	if bmi <= 18:
		print('1')
	elif bmi > 18 and bmi < 25:
		print('2')
	elif bmi >= 25 and bmi < 30:
		print('3')
	else:
		print('4')


for _ in range(int(input())):
	(m, h) = map(int, input().split())
	a = m / (h * h)
	if a <= 18:
		print('1')
	elif a > 18 and a <= 24:
		print('2')
	elif a >= 25 and a <= 29:
		print('3')
	else:
		print('4')


for _ in range(int(input())):
	(M, H) = map(int, input().split())
	bmi = M / H ** 2
	if bmi <= 18:
		print('1')
	elif bmi >= 19 and bmi <= 24:
		print('2')
	elif bmi >= 25 and bmi <= 29:
		print('3')
	else:
		print('4')


for i in range(int(input())):
	(m, h) = map(int, input().split())
	bmi = int(m / (h * h))
	if bmi <= 18:
		print('1')
	elif bmi > 18 and bmi <= 24:
		print('2')
	elif bmi > 24 and bmi <= 29:
		print('3')
	else:
		print('4')


t = int(input())
for i in range(t):
	(m, h) = map(int, input().split(' '))
	if m / h ** 2 <= 18:
		print(1)
	elif m / h ** 2 in range(19, 25):
		print(2)
	elif m / h ** 2 in range(25, 30):
		print(3)
	else:
		print(4)


for _ in range(int(input())):
	(M, H) = map(int, input().split())
	normal = [19, 20, 21, 22, 23, 24]
	overweight = [25, 26, 27, 28, 29]
	BMI = M // (H * H)
	if BMI <= 18:
		print(1)
	elif BMI in normal:
		print(2)
	elif BMI in overweight:
		print(3)
	else:
		print(4)


p = int(input())
for i in range(p):
	(x, y) = map(int, input().split())
	a = x // y ** 2
	if a <= 18:
		print(1)
	elif a >= 19 and a <= 24:
		print(2)
	elif a >= 25 and a <= 29:
		print(3)
	else:
		print(4)


t = int(input())
for p in range(t):
	nn = input()
	nn = nn.split(' ')
	a = int(nn[0])
	b = int(nn[1])
	bmi = a / (b * b)
	if bmi <= 18:
		print(1)
	elif bmi >= 19 and bmi <= 24:
		print(2)
	elif bmi >= 25 and bmi <= 29:
		print(3)
	else:
		print(4)


n = int(input())
for _ in range(n):
	(M, H) = list(map(int, input().split()))
	BMI = M / (H * H)
	if BMI <= 18:
		print(1)
	elif BMI >= 19 and BMI < 25:
		print(2)
	elif BMI >= 25 and BMI < 30:
		print(3)
	else:
		print(4)


t = int(input())
for i in range(t):
	(M, H) = map(int, input().split())
	a = M / (H * H)
	if a <= 18:
		print(1)
	elif 19 <= a <= 24:
		print(2)
	elif 25 <= a <= 29:
		print(3)
	else:
		print(4)


t = int(input())
while t > 0:
	(m, h) = map(int, input().split())
	bmi = m / h ** 2
	if bmi <= 18:
		print('1')
	elif bmi >= 19 and bmi <= 24:
		print('2')
	elif bmi >= 25 and bmi <= 29:
		print('3')
	elif bmi >= 30:
		print('4')
	t -= 1


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a / b ** 2 <= 18:
		print(1)
	elif 19 <= a / b ** 2 <= 24:
		print(2)
	elif 25 <= a / b ** 2 <= 29:
		print(3)
	else:
		print(4)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a / (b * b) <= 18:
		print(1)
	elif 19 <= a / (b * b) <= 24:
		print(2)
	elif 25 <= a / (b * b) <= 29:
		print(3)
	elif a / (b * b) >= 30:
		print(4)


for _ in range(int(input())):
	(V, H) = map(int, input().split())
	bmi = V / H ** 2
	if bmi <= 18:
		print(1)
	elif bmi > 18 and bmi <= 24:
		print(2)
	elif bmi > 24 and bmi <= 29:
		print(3)
	else:
		print(4)


T = int(input(''))

def bmi():
	(M, H) = map(int, input().split())
	bmi = M / H ** 2
	if bmi <= 18:
		return 1
	elif 19 <= bmi <= 24:
		return 2
	elif 25 <= bmi <= 29:
		return 3
	elif bmi >= 30:
		return 4
while T > 0:
	print(bmi())
	T = T - 1


for i in range(int(input())):
	(M, H) = map(int, input().split())
	bmi = M / H ** 2
	if bmi <= 18:
		print(1)
	elif bmi > 18 and bmi <= 24:
		print(2)
	elif bmi > 24 and bmi <= 29:
		print(3)
	else:
		print(4)


for i in range(int(input())):
	(m, h) = map(int, input().split())
	res = m // h ** 2
	if res <= 18:
		print('1')
	elif res > 18 and res <= 24:
		print('2')
	elif res >= 25 and res <= 29:
		print('3')
	elif res >= 30:
		print('4')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = b * b
	d = a // c
	if d <= 18:
		print(1)
	elif d >= 19 and d <= 24:
		print(2)
	elif d >= 25 and d <= 29:
		print(3)
	elif d >= 30:
		print(4)


t = int(input())
for _ in range(t):
	(m, h) = map(int, input().split())
	h = pow(h, 2)
	if m // h <= 18:
		print(1)
	elif m // h <= 24:
		print(2)
	elif m // h <= 29:
		print(3)
	else:
		print(4)


n = int(input())
for i in range(n):
	(m, h) = list(map(int, input().split()))
	bmi = m // (h * h)
	if bmi <= 18:
		print('1')
	elif 19 <= bmi <= 24:
		print('2')
	elif 25 <= bmi <= 29:
		print('3')
	elif bmi >= 30:
		print('4')


for _ in range(int(input())):
	(Mon, Hon) = map(int, input().split())
	bmi = Mon / Hon ** 2
	if bmi <= 18:
		print(1)
	elif bmi > 18 and bmi <= 24:
		print(2)
	elif bmi > 24 and bmi <= 29:
		print(3)
	else:
		print(4)


T = int(input())
a = [19, 20, 21, 22, 23, 24]
b = [25, 26, 27, 28, 29]
for i in range(T):
	(M, H) = map(int, input().split())
	if M / H ** 2 <= 18:
		print('1')
	elif M / H ** 2 in a:
		print('2')
	elif M / H ** 2 in b:
		print('3')
	else:
		print('4')


for _ in range(int(input())):
	(m, h) = map(int, input().split())
	bmi = round(m // h ** 2)
	if bmi <= 18:
		print(1)
	elif bmi > 18 and bmi < 25:
		print(2)
	elif bmi >= 25 and bmi <= 29:
		print(3)
	elif bmi >= 30:
		print(4)


t = int(input())
while t > 0:
	(M, H) = map(int, input().split())
	C = M / (H * H)
	if C <= 18:
		print(1)
	elif C >= 19 and C <= 24:
		print(2)
	elif C >= 25 and C <= 29:
		print(3)
	else:
		print(4)
	t = t - 1


T = int(input())
for i in range(T):
	(M, H) = map(int, input().split())
	res = M / (H * H)
	if res <= 18:
		print(1)
	elif res < 25:
		print(2)
	elif res < 30:
		print(3)
	else:
		print(4)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = a // (b * b)
	if c <= 18:
		print('1')
	elif c >= 19 and c <= 24:
		print('2')
	elif c >= 25 and c <= 29:
		print('3')
	else:
		print('4')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	b = a / b ** 2
	l = 1 if b <= 18 else 2 if b <= 24 else 3 if b <= 29 else 4
	print(l)


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	bmi = x / (y * y)
	if bmi <= 18:
		print(1)
	elif bmi >= 19 and bmi <= 24:
		print(2)
	elif bmi >= 25 and bmi <= 29:
		print(3)
	elif bmi >= 30:
		print(4)


def BMI(x, y):
	g = x // (y * y)
	if g <= 18:
		print('1')
	elif g >= 18 and g <= 24:
		print('2')
	elif g >= 25 and g <= 29:
		print('3')
	else:
		print('4')
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	ans = BMI(a, b)


t = int(input())
while t > 0:
	t = t - 1
	(a, b) = list(input().split())
	a = int(a)
	b = int(b)
	c = a / (b * b)
	if c <= 18:
		print('1')
	elif c >= 19 and c <= 24:
		print('2')
	elif c >= 25 and c <= 29:
		print('3')
	else:
		print('4')


def code():
	cases = int(input())
	for _ in range(cases):
		(M, H) = map(int, input().split(' '))
		bmi = M / H ** 2
		category = 0
		if bmi >= 30:
			category = 4
		if bmi <= 29 and bmi >= 25:
			category = 3
		if bmi <= 24 and bmi >= 19:
			category = 2
		if bmi <= 18:
			category = 1
		print(category)
code()


for i in range(int(input())):
	(m, h) = map(int, input().split())
	f = m / (h * h)
	if f <= 18:
		print('1')
	elif f == 19 or f == 20 or f == 21 or (f == 22) or (f == 23) or (f == 24):
		print('2')
	elif f == 25 or f == 26 or f == 27 or (f == 28) or (f == 29):
		print('3')
	else:
		print('4')