Thunder Bitz

Codechef

Four Arrays Codechef Solution | May CHALLENGE

Four Arrays Codechef Solution You have been given an integer KK and four arrays AA, BB, CC, and DD with sizes SASA, SBSB, SCSC and SDSD respectively. Follow the given steps: Pick four indices xx, yy, zz, and ww from arrays AA, BB, CC, and DD respectively. Note that (1≤x≤SA)(1≤x≤SA), (1≤y≤SB)(1≤y≤SB), (1≤z≤SC)(1≤z≤SC) and (1≤w≤SD)(1≤w≤SD). There are in total SA×SB×SC×SDSA×SB×SC×SD ways to do the above step. For each way, write down the value of (Ax+By)×(Cz+Dw)(Ax+By)×(Cz+Dw) on a board. Sort all the numbers written on the board in non-decreasing order. Find the KthKth element …

Four Arrays Codechef Solution | May CHALLENGE Read More »

Codechef

In The Green Zone Codechef Solution | May CHALLENGE

In The Green Zone Codechef Solution There are NN cans lying on the X-axis at points XiXi (1≤i≤N)(1≤i≤N). Each of the N cans is associated with two values AiAi and BiBi. Also, the segment between the points LL and RR (L≤R)(L≤R) is considered to be green zone including the points LL and RR. There are two types of operations – 1.1. Select a can ii out of the NN cans and move it one unit in …

In The Green Zone Codechef Solution | May CHALLENGE Read More »

Codechef

The Magical Stone Codechef Solution | May CHALLENGE

The Magical Stone Codechef Solution Initially, there is a magical stone of mass 2N2N lying at the origin of the number line. For the next NN seconds, the following event happens: Let us define the decomposition of a magical stone as follows: If there is a magical stone of mass M>1M>1 lying at coordinate XX, then it decomposes into two magical stones, each of mass M2M2 lying …

The Magical Stone Codechef Solution | May CHALLENGE Read More »

Codechef

Alternating Diameter Codechef Solution | May CHALLENGE

Alternating Diameter Codechef Solution Chef stumbled upon BB black nodes and WW white nodes and now wants to construct a tree using them. Chef is bamboozled by the total number of trees that can be constructed using these nodes. To reduce this count, Chef considered only those trees which have at least one diameter that has alternating colors i.e. a black node …

Alternating Diameter Codechef Solution | May CHALLENGE Read More »

Codechef

Mystical Numbers Codechef Solution | May CHALLENGE

Mystical Numbers Codechef Solution A number MM is said to be a Mystical Number with respect to a number XX if (M⊕X)>(M&X)(M⊕X)>(M&X). You are given an array AA of size NN. You are also given QQ queries. Each query consists of three integers LL, RR, and XX. For each query, find the count of Mystical Numbers in the subarray A[L:R]A[L:R] with respect to the number XX. Notes: ⊕⊕ represents the Bitwise XOR operation and && represents the Bitwise AND operation. A[L:R]A[L:R] denotes the subarray A[L],A[L+1],…,A[R]A[L],A[L+1],…,A[R]. …

Mystical Numbers Codechef Solution | May CHALLENGE Read More »

Codechef

Pushpa Codechef Solution | May CHALLENGE

Pushpa Codechef Solution Pushpa has entered Chefland and wants to establish Pushpa-Raj here too. Chefland has NN towers where the height of the ithith tower is HiHi. To establish Pushpa-Raj, Pushpa does the following: Initially, Pushpa chooses any tower ii (1≤i≤N)(1≤i≤N) and lands on the roof of that tower. Let XX denote the height of the tower Pushpa is currently on, then, Pushpa can land on …

Pushpa Codechef Solution | May CHALLENGE Read More »

Codechef

The Attack of Queen Codechef Solution | May CHALLENGE

The Attack of Queen Codechef Solution Chef has started developing interest in playing chess, and was learning how the Queen moves. Chef has an empty N×NN×N chessboard. He places a Queen at (X,Y)(X,Y) and wonders – What are the number of cells that are under attack by the Queen? Notes: The top-left cell is (1,1)(1,1), the top-right cell is (1,N)(1,N), the bottom-left cell is (N,1)(N,1) and …

The Attack of Queen Codechef Solution | May CHALLENGE Read More »

Codechef

Sugarcane Juice Business Codechef Solution | May CHALLENGE

Sugarcane Juice Business Codechef Solution While Alice was drinking sugarcane juice, she started wondering about the following facts: The juicer sells each glass of sugarcane juice for 5050 coins. He spends 20%20% of his total income on buying sugarcane. He spends 20%20% of his total income on buying salt and mint leaves. He spends 30%30% of his total income on shop rent. Alice wonders, …

Sugarcane Juice Business Codechef Solution | May CHALLENGE Read More »

x