## Count Luck

Ron and Hermione are deep in the Forbidden Forest collecting potion ingredients, and they've managed to lose their way. The path out of the forest is blocked, so they must make their way to a portkey that will transport them back to Hogwarts. Consider the forest as an grid. Each cell is either empty (represented by .) or blocked by a tree (represented by ). Ron and Hermione can move (together inside a single cell) LEFT, RIGHT, UP, and DOWN through empty cells, but they cannot travel through

View Solution →## Cut the Tree

There is an undirected tree where each vertex is numbered from 1 to n, and each contains a data value. The sum of a tree is the sum of all its nodes' data values. If an edge is cut, two smaller trees are formed. The difference between two trees is the absolute value of the difference in their sums. Given a tree, determine which edge to cut so that the resulting trees have a minimal difference between them, then return that difference. The minimum absolute difference is . Note: The giv

View Solution →## Making Candies

Karl loves playing games on social networking sites. His current favorite is CandyMaker, where the goal is to make candies. Karl just started a level in which he must accumulate candies starting with machines and workers. In a single pass, he can make candies. After each pass, he can decide whether to spend some of his candies to buy more machines or hire more workers. Buying a machine or hiring a worker costs units, and there is no limit to the number of machines he can own or workers h

View Solution →## Gena Playing Hanoi

The Tower of Hanoi is a famous game consisting of rods and a number of discs of incrementally different diameters. The puzzle starts with the discs neatly stacked on one rod, ordered by ascending size with the smallest disc at the top. The game's objective is to move the entire stack to another rod, obeying the following rules: Only one disk can be moved at a time. In one move, remove the topmost disk from one rod and move it to another rod. No disk may be placed on top of a smaller disk.

View Solution →## Beautiful Quadruples

We call an quadruple of positive integers, , beautiful if the following condition is true: Note: is the bitwise XOR operator. Given , , , and , count the number of beautiful quadruples of the form where the following constraints hold: When you count the number of beautiful quadruples, you should consider two quadruples as same if the following are true: They contain same integers. Number of times each integers occur in the quadruple is same. For example and should be considered

View Solution →