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

Expected move Solution Codechef

June Long Challenge 2022 Solution

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

Reduce to zero Solution Codechef

June Long Challenge 2022 Solution

Reduce to zero Solution Codechef Chef has two integers X and Y. Chef wants to perform some operations to make both X and Y zero simultaneously. In one operation, Chef can either: set X := 2 ⋅ X or set Y := 2 ⋅ Y or set X := X – 1 and Y := Y – 1 Chef is a little busy with preparing the contest. … Read more

Full Path Eraser Solution Codechef

June Long Challenge 2022 Solution

Full Path Eraser Solution Codechef There is a rooted tree of N vertices rooted at vertex 1. Each vertex v has a value Av​ associated with it. You choose a vertex v (possibly the root) from the tree and remove all vertices on the path from the root to the vertex v, also including v. This will result in a forest of zero or more connected … Read more

Codechef June Long Challenge 2022 Solution

June Long Challenge 2022 Solution

Codechef June Long Challenge 2022 solution is about to start in next few days. During May Long Challenge we were able to update the solutions on time, we hope to do our best this time. We got great response and reach in terms of audience. We provide Coding Resources for AMCAT, GeekforGeeks, Coding Ninja, Amazon … Read more