## Xor and Sum

You are given two positive integers a and b in binary representation. You should find the following sum modulo 10^9 + 7: where operation xor means exclusive OR operation, operation shl means binary shift to the left. Please note, that we consider ideal model of binary integers. That is there is infinite number of bits in each number, and there are no disappearings (or cyclic shifts) of bits. Input Format The first line contains number a (1 <= a <2^10^5) in binary representation. The

View Solution →## Lego Blocks

You have an infinite number of 4 types of lego blocks of sizes given as (depth x height x width): d h w 1 1 1 1 1 2 1 1 3 1 1 4 Using these blocks, you want to make a wall of height n and width m. Features of the wall are: - The wall should not have any holes in it. - The wall you build should be one solid structure, so there should not be a straight vertical break across all rows of bricks. - The bricks must be laid horizontally. How many ways can the wall be built? Example

View Solution →## Brick Tiling

You are given a grid having N rows and M columns. A grid square can either be blocked or empty. Blocked squares are represented by a '#' and empty squares are represented by '.'. Find the number of ways to tile the grid using L shaped bricks. A L brick has one side of length three units while other of length 2 units. All empty squares in the grid should be covered by exactly one of the L shaped tiles, and blocked squares should not be covered by any tile. The bricks can be used in any orientatio

View Solution →## Alien Languages

Sophia has discovered several alien languages. Suprisingly, all of these languages have an alphabet, and each of them may contain thousands of characters! Also, all the words in a language have the same number of characters in it. However, the aliens like their words to be aesthetically pleasing, which for them means that for the ith letter of an n-letter alphabet (letters are indexed 1 . . . n ): if 2i > n, then the ith letter may be the last letter of a word, or it may be immediately fo

View Solution →## Stock Maximize

Your algorithms have become so good at predicting the market that you now know what the share price of Wooden Orange Toothpicks Inc. (WOT) will be for the next number of days. Each day, you can either buy one share of WOT, sell any number of shares of WOT that you own, or not make any transaction at all. What is the maximum profit you can obtain with an optimum trading strategy? Example prices = [1,2] Buy one share day one, and sell it day two for a profit of 1. Return 1. prices = [2,1]

View Solution →