Subscriptions Solution Codechef

June Long Challenge 2022 Solution

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

June Long Challenge 2022 Solution

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

Equal Strings Solution Codechef

June Long Challenge 2022 Solution

Equal Strings Solution Codechef Given a string A of length N consisting of lowercase English alphabet letters. You are allowed to perform the following operation on the string A any number of times: Select a non-empty subsequence S of the array [1,2,3,…,N] and any lowercase English alphabet α; Change Ai​ to α for all i∈S. Find the minimum number of operations required to convert A into a given string B of length N consisting of lowercase English alphabet letters. … Read more

Divisible by i Solution Codechef

June Long Challenge 2022 Solution

Divisible by i Solution Codechef You are given an integer N. Construct a permutation P of length N such that For all i (1≤i≤N-1), i divides abs(Pi+1​−Pi​). Recall that a permutation of length N is an array where every integer from 1 to N occurs exactly once. It can be proven that for the given constraints at least one such P always exists. Input Format The first line of input contains a … Read more

Possible GCD Solution Codechef

June Long Challenge 2022 Solution

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