Counting the Ways
Little Walter likes playing with his toy scales. He has N types of weights. The ith weight type has weight ai. There are infinitely many weights of each type. Recently, Walter defined a function, F(X), denoting the number of different ways to combine several weights so their total weight is equal to X. Ways are considered to be different if there is a type which has a different number of weights used in these two ways. For example, if there are types of weights with corresonding weights 1
View Solution →Hard Disk Drives
There are n pairs of hard disk drives (HDDs) in a cluster. Each HDD is located at an integer coordinate on an infinite straight line, and each pair consists of one primary HDD and one backup HDD. Next, you want to place k computers at integer coordinates on the same infinite straight line. Each pair of HDDs must then be connected to a single computer via wires, but a computer can have any number (even zero) of HDDs connected to it. The length of a wire connecting a single HDD to a computer is
View Solution →Separate the chocolate
Tom and Derpina have a rectangular shaped chocolate bar with chocolates labeled T, D and U. They want to split the bar into exactly two pieces such that: Tom's piece can not contain any chocolate labeled D and similarly, Derpina's piece can not contain any chocolate labeled T and U can be used by either of the two. All chocolates in each piece must be connected (two chocolates are connected if they share an edge), i.e. the chocolates should form one connected component The absolute differen
View Solution →Find Digits
An integer d is a divisor of an integer n if the remainder of n/d = 0. Given an integer, for each digit that makes up the integer determine whether it is a divisor. Count the number of divisors occurring within the integer. Example n = 124 Check whether 1, 2 and 4 are divisors of 124. All 3 numbers divide evenly into 124 so return 3. n = 111 Check whether 1, 1, 1 and are divisors of 111. All 3 numbers divide evenly into 111 so return 3. n = 10 Check whether 1 and 0 are divisors
View Solution →Extra long Factorials
The factorial of the integer n, written n!, is defined as: n! = n * (n-1) * (n-2) * ........ * 3 * 2 * 1 Calculate and print the factorial of a given integer. For example, if n = 30, we calculate 30 * 29 * 28 * ...... * 3 * 2 * 1 and get 265252859812191058636308480000000. Function Description Complete the extraLongFactorials function in the editor below. It should print the result and return. extraLongFactorials has the following parameter(s): n: an integer Note: Fac
View Solution →