# Month: September 2021

## Chef lives in an N×MN×M grid. He is currently participating in a treasure hunt, and has two items left to find. Chef knows that the Manhattan distance between the cells containing these two items is exactly kk. He wants to know, in how many different pairs of cells can the two items be present?- Chef lives in an N×MN×M grid. He is currently participating in a treasure hunt, and has two items left to find. Chef knows that the Manhattan distance between the cells containing these two items is exactly kk. He wants to know, in how many different pairs of cells can the two items be present?

Treasure Hunt solution codechef Chef lives in an N×MN×M grid. He is currently participating in a treasure hunt, and has two items left to find. Chef knows that the Manhattan distance between the cells containing these two items is exactly kk. He wants to know, in how many different pairs of cells can the …

## This problem is similar to the problem “MNDIGSUM”. The only differences are in the constraints and in the input format. In this problem the range for the base BB is [2,R][2,R], the value of nn can be upto 10121012 and the total number of queries is at most 300300. The differences are described in bold.- This problem is similar to the problem “MNDIGSUM”. The only differences are in the constraints and in the input format. In this problem the range for the base BB is [2,R][2,R], the value of nn can be upto 10121012 and the total number of queries is at most 300300. The differences are described in bold.

Minimum Digit Sum 2 solution codechef This problem is similar to the problem “MNDIGSUM”. The only differences are in the constraints and in the input format. In this problem the range for the base BB is [2,R][2,R], the value of nn can be upto 10121012 and the total number of queries is at most 300300. The differences are described …

## You are given NN distinct points in a 22-D plane, numbered 11 through NN. The X-coordinate of the points are X1,X2,…,XNX1,X2,…,XN respectively and the Y-coordinates are Y1,Y2,…,YNY1,Y2,…,YN respectively. Your goal is to make the location of all the NN points equal to that of each other. To achieve this, you can do some operations.- You are given NN distinct points in a 22-D plane, numbered 11 through NN. The X-coordinate of the points are X1,X2,…,XNX1,X2,…,XN respectively and the Y-coordinates are Y1,Y2,…,YNY1,Y2,…,YN respectively. Your goal is to make the location of all the NN points equal to that of each other. To achieve this, you can do some operations.

2-D Point Meeting solution codechef You are given NN distinct points in a 22-D plane, numbered 11 through NN. The X-coordinate of the points are X1,X2,…,XNX1,X2,…,XN respectively and the Y-coordinates are Y1,Y2,…,YNY1,Y2,…,YN respectively. Your goal is to make the location of all the NN points equal to that of each other. To achieve this, you can do some operations. In one operation, you choose …

## You are given an array AA consisting of NN integers and an integer XX. Your goal is to have as many equal integers as possible in the array. To achieve this goal, you can do the following operation: Choose an index ii (1≤i≤N)(1≤i≤N) and set Ai=Ai⊕XAi=Ai⊕X, where ⊕⊕ denotes the bitwise xor operation. Find the maximum number of equal integers you can have in the final array and the minimum number of operations to obtain these many equal integers.- You are given an array AA consisting of NN integers and an integer XX. Your goal is to have as many equal integers as possible in the array. To achieve this goal, you can do the following operation: Choose an index ii (1≤i≤N)(1≤i≤N) and set Ai=Ai⊕XAi=Ai⊕X, where ⊕⊕ denotes the bitwise xor operation. Find the maximum number of equal integers you can have in the final array and the minimum number of operations to obtain these many equal integers.

XOR Equal solution codechef You are given an array AA consisting of NN integers and an integer XX. Your goal is to have as many equal integers as possible in the array. To achieve this goal, you can do the following operation: Choose an index ii (1≤i≤N)(1≤i≤N) and set Ai=Ai⊕XAi=Ai⊕X, where ⊕⊕ denotes the bitwise xor operation. Find the maximum number of …

## Let f(n,B)f(n,B) be the sum of digits of the integer nn when written in base BB. Given QQ queries, each consisting of three integers n,ln,l and rr. Find the value of BB corresponding to which f(n,B)f(n,B) is minimum for all l≤B≤rl≤B≤r. If there are multiple such values, you can print any of them.- Let f(n,B)f(n,B) be the sum of digits of the integer nn when written in base BB. Given QQ queries, each consisting of three integers n,ln,l and rr. Find the value of BB corresponding to which f(n,B)f(n,B) is minimum for all l≤B≤rl≤B≤r. If there are multiple such values, you can print any of them.

Minimize Digit Sum solution codechef Let f(n,B)f(n,B) be the sum of digits of the integer nn when written in base BB. Given QQ queries, each consisting of three integers n,ln,l and rr. Find the value of BB corresponding to which f(n,B)f(n,B) is minimum for all l≤B≤rl≤B≤r. If there are multiple such values, you can print any of them. Input Format Minimize Digit Sum solution codechef The …

## Chef is given an array AA consisting of NN positive integers. Chef shuffles the array AA and creates a new array BB of length NN, where Bi=(Ai+i)mod2Bi=(Ai+i)mod2, for each i(1≤i≤N)i(1≤i≤N). Find the maximum possible sum of integers of the array BB, if Chef shuffles the array AA optimally.- Chef is given an array AA consisting of NN positive integers. Chef shuffles the array AA and creates a new array BB of length NN, where Bi=(Ai+i)mod2Bi=(Ai+i)mod2, for each i(1≤i≤N)i(1≤i≤N). Find the maximum possible sum of integers of the array BB, if Chef shuffles the array AA optimally.

Shuffling Parities solution codechef Chef is given an array AA consisting of NN positive integers. Chef shuffles the array AA and creates a new array BB of length NN, where Bi=(Ai+i)mod2Bi=(Ai+i)mod2, for each i(1≤i≤N)i(1≤i≤N). Find the maximum possible sum of integers of the array BB, if Chef shuffles the array AA optimally. Input Format Shuffling Parities solution codechef The first line of the input contains …

## Chef is going on a road trip and needs to apply for inter-district and inter-state travel e-passes. It takes AA minutes to fill each inter-district e-pass application and BB minutes for each inter-state e-pass application. His journey is given to you as a binary string SS of length NN where 00 denotes crossing from one district to another district (which needs an inter-district e-pass), and a 11 denotes crossing from one state to another (which needs an inter-state e-pass).- Chef is going on a road trip and needs to apply for inter-district and inter-state travel e-passes. It takes AA minutes to fill each inter-district e-pass application and BB minutes for each inter-state e-pass application. His journey is given to you as a binary string SS of length NN where 00 denotes crossing from one district to another district (which needs an inter-district e-pass), and a 11 denotes crossing from one state to another (which needs an inter-state e-pass).

Travel Pass solution codechef Chef is going on a road trip and needs to apply for inter-district and inter-state travel e-passes. It takes AA minutes to fill each inter-district e-pass application and BB minutes for each inter-state e-pass application. His journey is given to you as a binary string SS of length NN where 00 denotes crossing from one district to …

## Chef has 33 bags that she wants to take on a flight. They weigh AA, BB, and CC kgs respectively. She wants to check-in exactly two of these bags and carry the remaining one bag with her. The airline restrictions says that the total sum of the weights of the bags that are checked-in cannot exceed DD kgs and the weight of the bag which is carried cannot exceed EE kgs. Find if Chef can take all the three bags on the flight.- Chef has 33 bags that she wants to take on a flight. They weigh AA, BB, and CC kgs respectively. She wants to check-in exactly two of these bags and carry the remaining one bag with her. The airline restrictions says that the total sum of the weights of the bags that are checked-in cannot exceed DD kgs and the weight of the bag which is carried cannot exceed EE kgs. Find if Chef can take all the three bags on the flight.

Airline Restrictions solution codechef Chef has 33 bags that she wants to take on a flight. They weigh AA, BB, and CC kgs respectively. She wants to check-in exactly two of these bags and carry the remaining one bag with her. The airline restrictions says that the total sum of the weights of the bags that are …

## You’re given a sequence of NN – distinct positive integers, not necessarily sorted in ascending order. Your task is pretty straightforward: sort the sequence in ascending order. At any point of time, you can perform one of the following operations: Deja Vu solution codechef- You’re given a sequence of NN – distinct positive integers, not necessarily sorted in ascending order. Your task is pretty straightforward: sort the sequence in ascending order. At any point of time, you can perform one of the following operations: Deja Vu solution codechef

stardevilm 5 seconds ago Uncategorized For Solution You’re given a sequence of NN – distinct positive integers, not necessarily sorted in ascending order. Your task is pretty straightforward: sort the sequence in ascending order. At any point of time, you can perform one of the following operations: Deja Vu …

## In order to expand its reach to the outer universe and ensure universal peace, the MIB has decided to expand its offices. Namely, it has established its office on NN most important planets in the universe, with the base station on the planet SS. Each office has an intergalactic teleporter that connects it to other planet offices. But the teleporters are bound to a planet’s policy, so you cannot teleport to any planet you wish.- In order to expand its reach to the outer universe and ensure universal peace, the MIB has decided to expand its offices. Namely, it has established its office on NN most important planets in the universe, with the base station on the planet SS. Each office has an intergalactic teleporter that connects it to other planet offices. But the teleporters are bound to a planet’s policy, so you cannot teleport to any planet you wish.

For Solution In order to expand its reach to the outer universe and ensure universal peace, the MIB has decided to expand its offices. Namely, it has established its office on NN most important planets in the universe, with the base station on the planet SS. Each office has an intergalactic teleporter that connects it to other planet …