Codechef•Jun 02, 2025
Chef and Candies
Hazrat Ali
Codechef
There are N children and Chef wants to give them 11 candy each. Chef already has X candies with him. To buy the rest, he visits a candy shop. In the shop, packets containing exactly 44 candies are available.
Determine the minimum number of candy packets Chef must buy so that he is able to give 11 candy to each of the N children.
Input Format
- The first line of input will contain a single integer T, denoting the number of test cases.
- The first and only line of each test case contains two integers N and X — the number of children and the number of candies Chef already has.
Output Format
For each test case, output the minimum number of candy packets Chef must buy so that he is able to give 11 candy to each of the N children.
Constraints
- 1≤T≤1000
- 1≤N,X≤100
Sample 1:
Input
4 20 12 10 100 10 9 20 9
Output
2 0 1 3
Solution
import math
m = int(input())
for _ in range(m):
n, x = map(int, input().split())
if x >= n:
print(0)
else:
candies = n - x
temp = math.ceil(candies / 4)
print(temp)