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 Output Format Constraints Sample 1: Input 2 … 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: Chef is a little busy with preparing the contest. Help him find the minimum number of operations required to make both X and Y equal to 0 simultaneously. If it is impossible to do so after … Read more