Question
– 1:
Mahirl
is a little girl who loves to play. Today she is playing by moving some stones
between two piles of stones. Initially, one of the piles has A and
the other has B stones in it.
Mahirl
has decided to perform a sequence of K operations. In each
operation she will double the size of the currently smaller pile. Formally, if
the current pile sizes are labeled X and Y in such a way that X <= Y, she
will move X stones from the second pile to the first one. After this move the
new pile sizes will be X+X and Y-X.
Given
the ints A, B, and K write a program
to determine the size of the smallest pile after Mahirl finishes all her
operations.
Input and Output Format:
Input
consists of 3 integers – A, B and K .
The
first integer corresponds to A, the number of stones in the first pile.
The
second integer corresponds to B, the number of stones in the second pile.
The
third integer corresponds to K, the number of operations performed.
Output
consists of an integer that corresponds to the size of the smallest pile.
Sample Input :
4
7
2
Sample Output :
5
1 |
t7 |
1 |
0 |
2 |
t3 |
2 |
4 |
3 |
t2 |
5 |
0 |
4 |
t4 |
2 |
4 |
5 |
t10 |
231 |
Question
– 2:
A
man is doing a something experiment with the device that he built newly. The
structure of the device is shown as below diagram
B
to E is a sloping surface with n holes, labeled H1, H2, H3...
Hn, on it. Holes are of different diameters & depths. The man is
releasing m number of balls of different diameters from the point B one after
the other. He wants to find the positions of each ball after the
experiment. The specialties of the device are as follow:
1. A ball will fall into
a hole, if and only if its diameter is less than or equal to the diameter of
the hole.
2. A hole Hi will
become Non-empty i.e Full, if i no. of balls fall into it. For ex hole labeled
as H3 will become full if THREE balls fall into it.
3. If a hole is full then
no more balls can fall into that hole.
4. A ball will reach the
bottom point E from B, only if it is not falling into any 1 of the holes.
Please
help him in finding the eventual position of the balls. If a ball is in hole Pi,
then take its position as i. If a ball reached the bottom point E, then take
its position as 0.
Constraints
·
0 < N <= 50
·
0 < Diameter of holes <= 10^9
·
0 < M <= 1000
·
0 < M <= 1000
Input
Format
Line
1: total number of holes, N
Line
2: N space separated integers
denoting the diameters of N holes, from bottom to top
Line
3: total number of balls, M
Line
4: M space separated integers
denoting the diameters of balls in the order of release.
Output
Line
1: Positions of each ball in the
order of ball release separated by space
Explanation
Input
3
21
3 6
11
20
15 5 7 10 4 2 1 3 6 8
Output
1
0 3 0 0 3 3 2 2 0 0