Computer Science, asked by shashankagnihotri, 1 year ago

an activist of a banned organisation plans to escape from jail. the ctivist is basically a monkey man and is able to jump across the wall. he is able to jump 'x' metres, but because of the slippery wall he falls 'y' metres after each jump. to escape from jail, he has to cross 'n' number of walls, where height of each wall is given in an array.
write a program to find the total number of jumps he has make, to escape from jail.

Answers

Answered by sawakkincsem
1
You should write a program, first of all, you will add input format which will be the following: 

1. An integer depicting X
2. An integer depicting Y
3. And an array of N integers which will be having the height of the wall

following will be the constraints:

1< = X <=109
1< = Y <= 105

and the output format will be the following:
The program should be able to return the total number of jumps which are required to escape.

for example there is a test case
sample input 
10
1
1
10

the sample output will be 
1

the explanation for this is:
that the activist can jump 10 meters high but also slides down by 1 meter and there is a 1 wall which he wants to jump and the height of the wall is also 10 meters. So when he jumps 10 meters in the first attempt he will be able to cross the wall easily in the first attempt.
Answered by alinakincsem
2
The program should be written in a way that the input information should be added and the integers should be used for X and Y and N will be used to show the height of the wall, with the following program the jumps can be measured.

1< = X <=109
1< = Y <= 105

With the above-mentioned program, the answer will be 1 and the activist will be able to escape on his first attempt because there is only 1 wall and the height of the wall is 10 meters, so the activist will be able to jump the wall and be able to escape in his first attempt.
Similar questions