saai
a java question
0 Answer(s)      3 years and 8 months ago
Posted in : JavaScript Questions

A thief Muthhooswamy planned to escape from *** jail. Muthhooswamy is basically a monkey man and he is able to jump across the wall. He practiced to cross a wall and he is able to jump 'X' meters, but because of slippery wall he fall 'Y' meters 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 out the total number of jumps he will make to escape from the jail.

Input Specifications

Your program must read 4 arguments (climbUp, climbDown, noOfWalls,wallHeights[]) where

climbUp is the number of metres he can jump (1<=climbUp<=10^10) climbDown is the number of metres he slides down (1<=climbDown<=10^5) noOfWalls is the number of walls he needs to jump to escape (1<=noOfWalls<=10^5) wallHeights[] is a single dimensional array where the height of each wall is provided, the ith element is (1<=i<=1000)

Output Specifications

Your program should return total number of jumps to the output variable output1 provided

Examples

Sample Input 1: 10:1:1:{10} Here Muthooswamy can jump 10 metres height but slides down by 1 metre. He has 1 wall to jump and the height of the wall is 10 metres. Since he jumps 10 metres in the first attempt he cross the wall easily in the first attempt only.

Sample Output 1: 1

Sample Input 2: 5:1:2:{9,10} Here Muthooswamy can jump 5 metres height but slides down by 1 metre. He has 2 walls to jump and the height of each wall is 9 and 10 metres respectively.

While crossing the first wall, Muthooswamy takes 2 attempts because during the first attempt he jumps 5 metres but slides down by 1 metre since he didn't cross the wall. In the next attempt he jumps 5 more metres from that position and this time he doesn't slide because he crossed the wall in this attempt because 4+5=9 and 9 metres is the actual height of the wall.

Similarly while crossing the second wall, Muthooswamy takes 3 attempts because during his second attempt on this wall, he slides down by 1 metre since 4+5=9 and the height of the wall is 10 metres. During his third attempt, Muthooswamy was able to escape from ***

Sample Output 2: 5

Advertisement
View Answers









Related Tutorials/Questions & Answers:
Question in Java ??
Question in Java ??   Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number squrfoot
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Advertisements
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Question on java
Question on java  why java is not purely oop?   java is not purely OOP because 1.) Multiple Inheritance is not supported. 2.) It uses primitive data type. 3.) static method can be called without creating instances
Question Java>?
Question Java>?  **ï??· Create a new class called Bank and in the main method use class Account (lab 4) to create an array of 10 accounts. ï??· Enter data for all accounts (account number,name, balance). ï??· Add
java question
java question   Create a class called Complex to perform arithmetic operations with complex numbers. 1- Use double variables to represent the fields of the class. 2- Provide a no-argument constructor with default values in case
java question :)
java question :)  write java program to use vector in ArrayList with add, remove,sort   import java.util.Vector; public class... Element MUAYAD"); vc.add("Vector Element JAVA"); vc.add("Vector Element
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
java question
java question  find the 127 twin pair in java
java question
java question  the purpose of defining multiple constructor in java
java question
java question  what is the difference between path and classpath in java
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
java question
java question  How to find the longest and shortest line from the file in case of java and java program should read the filename from the keyboard
java question
java question  wats dynamic dispatching
java question
java question  how to write a java program that, given a friend name , display the phone number and the email address for that friend
java question
java question  Please, give me sample program for insert Audio(sound) on Frame in swing in java
java question
java question  anyone provide the code to call c++ function from java   Here you will find details how to implement the c++ into the java. http://www.javaworld.com/javatips/jw-javatip23.html
Java Question
Java Question  can u give me one expample in which conditions we... in java includes only abstract methods i.e. methods have signatures only (or we... in java defines that it must be implemented by any class to make use of it. One
java question
java question  what are the exactly J2EE concepts.. struts and hybernates coming under which catagiry
java question
java question  input any number and check if sum of alternate digit is palindrome
java question
java question  how to create date and time based pgm in java... in db table if date and time crossed automatically update in the db and inform to login user as pop ups   http://www.roseindia.net/jsp/loginstatus.shtml
java question
java question  i wrote to java code to get data populated in the Revision field of table InventDim 2.Failing to successfully do the above, i tried to use the ConfigId field of table InventDim for the same purpose, by labeling
java question
java question  sir, can you give me the code for online banking using netbeans and mysql in j2ee with its database connectivity
java question
java question  sir, can you give me the code for online banking using netbeans and mysql in j2ee with its database connectivity
java question
java question  when we use the Abstract class and interface?   Please visit the following link: Abstract class and Interface
java question
java question  Can any one send me the source code to get confirmation after the successful registration to our mobile
java question
java question  I am converting a .net website into java one. Can you help me how to code things step by step. project name - src -java -main -webapp - common - jsp - css - images - javascripts I
Java question
Java question  Write a program that converts a (C to F Converter from 0 - 20) and writes the output to a file instead of the screen. Open the file in Notepad to confirm the output
java question
java question  i have a string like "My name is arvind.i live in bangalore.i study in college.".the problem is that i hav to break this string into three seperate lines
java Question
java Question  write a program that reads an integer and check whether it is even. for example, if your input is 25, the should be: is 25 an even number? false if your input is 2000, the should be: is 2000 an even number?true