Knowee
Questions
Features
Study Tools

Chef is making cookies for 𝑁N kids. He wants to give everyone an equal number of cookies. He must give at least 11 cookie to each kid.Chef already has 𝑀M cookies.He can destroy or make 11 cookie in 11 second.Find the minimum time after which he can evenly distribute the cookies between all kids.Input FormatThe first line of input will contain a single integer 𝑇T, denoting the number of test cases.Each test case consists of a single line of input.The first and only line of each test case contains 𝑁N and 𝑀M - the number of kids and the initial number of cookies.Output FormatFor each test case, output on a new line the minimum time such that Chef can evenly distribute all his cookies.Constraints1≤𝑇≤1041≤T≤10 4 1≤𝑁,𝑀≤1091≤N,M≤10 9 Sample 1:InputOutput45 175 184 12 182230Explanation:Test Case 1 : Chef destroys 22 cookies to have 1515 cookies total. This takes 22 seconds. Now, he can distribute all his cookies by giving every kid 33 cookies each.Test Case 2 : Chef makes 22 cookies to have 2020 cookies total. This takes 22 seconds again. Now, he can distribute all his cookies by giving every kid 44 cookies each.Test Case 3 : Chef makes 33 more cookies to have 44 cookies total, and he gives 11 each to the 44 kids. Note that Chef can't destroy 11 cookie and then evenly distribute, as he needs to give everyone at least 11 cookie.

Question

Chef is making cookies for 𝑁N kids. He wants to give everyone an equal number of cookies. He must give at least 11 cookie to each kid.Chef already has 𝑀M cookies.He can destroy or make 11 cookie in 11 second.Find the minimum time after which he can evenly distribute the cookies between all kids.Input FormatThe first line of input will contain a single integer 𝑇T, denoting the number of test cases.Each test case consists of a single line of input.The first and only line of each test case contains 𝑁N and 𝑀M - the number of kids and the initial number of cookies.Output FormatFor each test case, output on a new line the minimum time such that Chef can evenly distribute all his cookies.Constraints1≤𝑇≤1041≤T≤10 4 1≤𝑁,𝑀≤1091≤N,M≤10 9 Sample 1:InputOutput45 175 184 12 182230Explanation:Test Case 1 : Chef destroys 22 cookies to have 1515 cookies total. This takes 22 seconds. Now, he can distribute all his cookies by giving every kid 33 cookies each.Test Case 2 : Chef makes 22 cookies to have 2020 cookies total. This takes 22 seconds again. Now, he can distribute all his cookies by giving every kid 44 cookies each.Test Case 3 : Chef makes 33 more cookies to have 44 cookies total, and he gives 11 each to the 44 kids. Note that Chef can't destroy 11 cookie and then evenly distribute, as he needs to give everyone at least 11 cookie.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

To solve this problem, we need to calculate the difference between the number of cookies Chef currently has and the number of cookies he needs to evenly distribute to all kids.

Here are the steps to solve this problem:

  1. First, calculate the number of cookies Chef needs to evenly distribute to all kids. This can be done by taking the modulus of the number of cookies Chef currently has

Similar Questions

Explanation:Test Case 1 : Chef destroys 22 cookies to have 1515 cookies total. This takes 22 seconds. Now, he can distribute all his cookies by giving every kid 33 cookies each.Test Case 2 : Chef makes 22 cookies to have 2020 cookies total. This takes 22 seconds again. Now, he can distribute all his cookies by giving every kid 44 cookies each.Test Case 3 : Chef makes 33 more cookies to have 44 cookies total, and he gives 11 each to the 44 kids. Note that Chef can't destroy 11 cookie and then evenly distribute, as he needs to give everyone at least 11 cookie.

Chef and Instant NoodlesChef has invented 11-minute Instant Noodles. As the name suggests, each packet takes exactly 11 minute to cook.Chef's restaurant has 𝑋X stoves and only 11 packet can be cooked in a single stove at any minute.How many customers can Chef serve in 𝑌Y minutes if each customer orders exactly 11 packet of noodles?Input FormatThe first and only line of input contains two space-separated integers 𝑋X and 𝑌Y — the number of stoves and the number of minutes, respectively.Output FormatPrint a single integer, the maximum number of customers Chef can serve in 𝑌Y minutesConstraints1≤𝑋,𝑌≤10001≤X,Y≤1000Sample 1:InputOutput3 721Explanation:Chef cooks for 𝑌=7Y=7 minutes and can cook 𝑋=3X=3 packets per minute, one on each stove.So, the total number of packets that can be cooked is 𝑋⋅𝑌=3⋅7=21X⋅Y=3⋅7=21.Each person orders one packet, so the maximum number of customers that can be served is 2121.

Chef's son wants to go on a roller coaster ride. The height of Chef's son is 𝑋X inches while the minimum height required to go on the ride is 𝐻H inches. Determine whether he can go on the ride or not.Input FormatThe first line contains a single integer 𝑇T - the number of test cases. Then the test cases follow.The first and only line of each test case contains two integers 𝑋X and 𝐻H - the height of Chef's son and the minimum height required for the ride respectively.Output FormatFor each test case, output in a single line, YES if Chef's son can go on the ride. Otherwise, output NO.You may print each character of YES and NO in uppercase or lowercase (for example, yes, yEs, Yes will be considered identical)Constraints1≤𝑇≤10001≤T≤10001≤𝑋,𝐻≤1001≤X,H≤100Sample 1:InputOutput415 2050 4832 3238 39NOYESYESNOExplanation:Test case 1: Chef's son can not go on the ride as his height << the minimum required height.Test case 2: Chef's son can go on the ride as his height ≥≥ the minimum required height.Test case 3: Chef's son can go on the ride as his height ≥≥ the minimum required height.Test case 4: Chef's son can not go on the ride as his height << the minimum required height.

Chef is eagerly waiting for a piece of information. His secret agent told him that this information would be revealed to him after 𝐾K weeks.𝑋X days have already passed and Chef is getting restless now. Find the number of remaining days Chef has to wait for, to get the information.It is guaranteed that the information has not been revealed to the Chef yet.Input FormatThe first line of input will contain an integer 𝑇T — the number of test cases. The description of 𝑇T test cases follows.The first and only line of each test case contains two space-separated integers 𝐾K and 𝑋X, as described in the problem statement.Output FormatFor each test case, output the number of remaining days that Chef will have to wait for.Constraints1≤𝑇≤5001≤T≤5001≤𝐾≤101≤K≤101≤𝑋<7⋅𝐾1≤X<7⋅KSample 1:InputOutput41 51 61 11 22165Explanation:Test case 11: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 55 days, so he needs to wait for 22 more days in order to get the information.Test case 22: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 66 days, so he needs to wait for 11 more day in order to get the information.Test case 33: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 11 day, so he needs to wait for 66 more days in order to get the information.Test case 44: The information will be revealed to the Chef after 11 week, which is equivalent to 77 days. Chef has already waited for 22 days, so he needs to wait for 55 more days in order to get the information.

Candy DistributionChef has 𝑁N candies. He has to distribute them to exactly 𝑀M of his friends such that each friend gets equal number of candies and each friend gets even number of candies. Determine whether it is possible to do so.NOTE: Chef will not take any candies himself and will distribute all the candies.Input FormatFirst line will contain 𝑇T, number of test cases. Then the test cases follow.Each test case contains of a single line of input, two integers 𝑁N and 𝑀M, the number of candies and the number of friends.Output FormatFor each test case, the output will consist of a single line containing Yes if Chef can distribute the candies as per the conditions and No otherwise.You may print each character of the string in uppercase or lowercase (for example, the strings yes, Yes, yEs, and YES will all be treated as identical).

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.