Chairs Requirement Solution Codechef

Chairs Requirement Solution Codechef Chef’s coding class is very famous in Chefland. This year X students joined his class and each student will require one chair to sit on. Chef already has Y chairs in his class. Determine the minimum number of new chairs Chef must buy so that every student is able to get one chair to sit … Read more

Subscriptions Solution Codechef

Subscriptions Solution Codechef A new TV streaming service was recently started in Chefland called the Chef-TV. A group of N friends in Chefland want to buy Chef-TV subscriptions. We know that 6 people can share one Chef-TV subscription. Also, the cost of one Chef-TV subscription is X rupees. Determine the minimum total cost that the group of N friends will incur so that … Read more

Alternate Additions Solution Codechef

Alternate Additions Solution Codechef Chef has 2 numbers A and B (A<B). Chef will perform some operations on A. In the ith operation: Chef will add 1 to A if i is odd. Chef will add 2 to A if i is even. Chef can stop at any instant. Can Chef make A equal to B? Input Format The first line contains a single integer T — the number of test cases. Then the test cases follow. The first and … Read more

Possible GCD Solution Codechef

Possible GCD Solution Codechef Chef has two distinct positive integers A and B. Chef wonders how many distinct values are possible for the expression gcd(A+X,B+X), where X can take any non-negative integer value. Help Chef find this value. Here, gcd stands for Greatest Common Divisor. Input Format The first line contains a single integer T — the number of test cases. Then the test cases follow. The first … Read more

Expected move Solution Codechef

Expected move Solution Codechef You are given a fair coin and two integers X and N. You repeatedly flip the coin and perform the following operation based on the result: If it lands on heads, then X will increase by 1. However, if X = N then X will not change. If it lands on tails, X will decrease by 1. You stop as soon as the value of X becomes 1. Find the expected number of … Read more