Posts
Problem link : https://toph.co/p/subodh Here, We can start coloring from any side of the wall. Lets start color from 1st wall. Now, it is greedily best option to color all the wall with color[1]. Now, I have to color wall from 2 to Nth. Here, there could be walls i in (2 to N) for which color[i] = color[1]. So, I have to choose a position i for which color[i] = color[1] , then this problem will be...
Subodh - Toph
Mar 26, 2023
22 views
First, let's check the impossible case. Impossible case : Let, lsb(x) be the position of the first bit from right which is set. Now, if lsb(a) < lsb(d) or lsb(b) < lsb(d) then it is impossible to find any x. prove : If Temp is any number and Val is divided by Temp. So, we can represent Val by Val = Temp x X. Val = Temp x (2 ^ 30 x i30 + .... + 2^1 x i1 + 2^0 x i0) Val = Temp x 2 ^ 30 x i30 +...
Codeforce - 1748D (ConstructOR)
Jan 04, 2023
18 views
Problem Link : https://codeforces.com/gym/102133/problem/G Suppose, the answer for N is X. Now, to find the answer for N+1 there could be two cases : If X is not divided by 2^(N+1) : As X is divided by 2^N and X is not divided by 2^(N+1) , the value of X % 2^(N+1) is equal to 2^N. We can prove this : X = y * 2^N (where y = 0, 1, 2, ......) Now, if y is even then X then X = y * 2^(N+1). So, X will ...
Moore's Law (Gym-102133G)
Dec 23, 2022
24 views