What's Next?
Johnny is playing with a large binary number, . The number is so large that it needs to be compressed into an array of integers, , where the values in even indices () represent some number of consecutive bits and the values in odd indices () represent some number of consecutive bits in alternating substrings of . For example, suppose we have array . represents , represents , represents , represents , and represents . The number of consecutive binary characters in the substring of cor
View Solution →String Transmission
Bob has received a binary string of length N transmitted by Alice. He knows that due to errors in transmission, up to K bits might have been corrupted (and hence flipped). However, he also knows that the string Alice had intended to transmit was not periodic. A string is not periodic if it cannot be represented as a smaller string concatenated some number of times. For example, "0001", "0110" are not periodic while "00000", "010101" are periodic strings. Now he wonders how many possible strin
View Solution →A or B
Consider four numbers: , , , and . You must change at most bits in and to form the numbers and satisfying the equation . Here, the | symbol denotes the bitwise OR operation. Given sets of the numbers defined above, find and print the respective values of and on new lines; if no such value exists, print instead. If there are multiple solutions, make as small as possible; if there are still multiple solutions, make as small as possible. Input Format The first line contains an i
View Solution →Manipulative Numbers
Suppose that is a list of numbers and is a permutation of these numbers, we say B is K-Manipulative if and only if: is not less than , where represents the XOR operator. You are given . Find the largest such that there exists a K-manipulative permutation . Input: The first line is an integer . The second line contains space separated integers - . Output: The largest possible , or if there is no solution.
View Solution →Stone Game
Alice and Bob are playing the game of Nim with piles of stones with sizes . If Alice plays first, she loses if and only if the 'xor sum' (or 'Nim sum') of the piles is zero, i.e., . Since Bob already knows who will win (assuming optimal play), he decides to cheat by removing some stones in some piles before the game starts. However, to reduce the risk of suspicion, he must keep at least one pile unchanged. Your task is to count the number of ways Bob can remove the stones to force Alice into
View Solution →