TCS Company Programming Program

Between Devil and Deep Sea

A band of pirates have made loot. By their misfortune though, instant Karma is delivered. While they are travelling a treacherous route in the high and the deep seas they are also haunted by a devil, perhaps a spirit who suffered at their hands previously. The pirates now have to make tricky decisions. They run forward to save themselves from the Devil, but the deep seas force them backwards. There is a danger of falling in a whirlpool if they move forward rashly and there is a danger of being caught by the Devil if they move too much back. But move they must.

First they recede backwards B meters and then advance forward F meters, in a straight line. They cover 1 meter in T units of time. This backward and forward movement is performed repeatedly by the Pirates because they have panicked.

Your task is to find out if they will perish at the hands of the Devil or they will get sucked into the whirlpool of the Deep Sea and in how much time. It is also possible that by good fortune they might survive. Write a program to calculate the outcome

Read Solution (Total 0)

TCS Other Question

A Milkman serves milk in packaged bottles of varied sizes. The possible size of the bottles are {1, 5, 7 and 10} litres. He wants to supply desired quantity using as less bottles as possible irrespective of the size. Your objective is to help him find the minimum number of bottles required to supply the given demand of milk.

Input Format:

First line contains number of test cases N
Next N lines, each contain a positive integer Li which corresponds to the demand of milk.

Output Format:

For each input Li, print the minimum number of bottles required to fulfill the demand

Constraints:

1 <= N <= 1000

Li > 0

1 <= i <= N

Sample Input and Output

SNo. Input Output
1
2
17
65


2
7



Explanation:

Number of test cases is 2

In first test case, demand of milk is 17 litres which can be supplied using minimum of 2 bottles as follows
1 x 10 litres and
1 x 7 litres
In second test case, demand of milk is 65 litres which can be supplied using minimum of 7 bottles as follows
6 x 10 litres and
1 x 5 litres
The power of compounding

Manish has realized the power of compounding. Since the days he started earning, he has diligently set aside a small corpus which he saves from his monthly salary and deposits in his bank account. Bank pays him interest every month. Manish is also a determined investor and refrains from withdrawing anything from this account because he now believes in power of compounding. Given investment corpus, fixed annual rate of interest and maturity period calculate the amount the Manish will end up saving at the end of his tenure.

Input Format:

First line contains investment corpus P
Second line contains rate of interest per annum R
Third line contains tenure T (in months)

Output Format:

Print the maturity amount after specified tenure in the format "Final_Amount "

Constraints:

P > 0 ; it can be float value

R >=0 ; it can be float value

T >0 ; it can be integer only

Calculation should be done upto 11-digit precision

Maturity amount should be printed, rounded off to its nearest integer value