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