Wednesday, 5 March 2014

Notice!!!

Solve as many problems as you can. Your time stamp will be recorded for each problem individually so send the solution as soon as possible. Best of Luck!!!

Problem 5

Aman is playing a game on a sequence of N positive integers, say A1, A2, ... AN. The game is played as follows.
*If all the numbers are equal, the game ends.
Otherwise
*Select two numbers which are unequal
**Subtract the smaller number from the larger number
***Replace the larger number with the result from above (see the explanation section for clarity)
Aman has already figured out that the game always terminates. He also knows, for a given sequence of integers, the game will always terminate on the same value, no matter how the game is played. Aman wants you to simulate the game for him and tell him on which value will the game terminate for a given sequence of integers.
Output a single integer - the value of all the numbers when they are equal (and the game terminates), on a line by itself

Sample Case 1:
input(10,12)=2
Explanation:Since there are only two numbers, the operations are forced.
*{ 10, 12 } => Replace 12 with ( 12 - 10 = 2 ) => { 10, 2 }
*{ 10, 2 } => Replace 10 with ( 10 - 2 = 8 ) => { 8, 2 }
*{ 8, 2 } => Replace 8 with ( 8 - 2 = 6 ) => { 6, 2 }
*{ 6, 2 } => Replace 6 with ( 6 - 2 = 4 ) => { 4, 2 }
*{ 4, 2 } => Replace 4 with ( 4 - 2 = 2 ) => { 2, 2 }

Sample Case 2:
input(6,10,15)=1

Problem 4

In this problem, you need to evaluate the expected value of the number of times we have non-zero carry when adding two non-negative integers that contain at most N digits each. Note that we are adding the numbers in their base 10 representation.

Sample Test Cases:
input(20,4)=0
input(111,119)=1
input(123,923)=1
input(1235,98765)=5

Problem 3

Given a line with W words separated by spaces. Reverse the order of words in the line.

Sample Input:
this is first input
Sample Output :
input first is this

Sample Input:
Aman
Sample Output :
Aman

Sample Input:
I Will be next DCL champ
Sample Output :
champ DCL next be Will I

Problem 2

Tom needs to make a rectangular box for his physics class project. He has bought P cm of wire and S (cm*cm) of special paper. He would like to use all the wire (for the 12 edges) and paper (for the 6 sides) to make the box.
Print a real number that is the largest volume of the box that Tom can make, rounded to two decimal places.

Sample Input 1:
20 14
Sample Output 1:
3.00
Output details: the dimensions of the largest box may be 3, 1 and 1.

Sample Input 1:
20 16
Sample Output 2:
4.15
Output details: the dimensions of the largest box may be 7/3, 4/3 and 4/3.