1. There is a building of n floors. There is an elevator in the building which...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. There is a building of “n” floors. There is an elevator in the building which has “UP” and “DOWN” buttons. By pressing the “UP” button, the elevator moves up exactly “a” floors. By pressing the "DOWN" button, the elevator moves down exactly "b" floors. If you attempt to move the elevator to lower than the first floor or higher than the "n"th floor, the elevator does not move. Now, you are in the "k" floor and want to go to the "m"th floor. Compute and print out the minimum number of times you should press the "UP" or "DOWN" buttons to go to the destination. Assume that l≤n≤ 9999. Input) The first line of the input should be the number of test cases. For each test case, a user should provide “n”, “a”, “b”, “k”, and “m” in order. Output) Print format should be "test #[testcase_number] [result] UP, [result] DOWN”, If there is no feasible solution, your program should print "IMPOSSIBLE", Sample) 3 10 1 1 8 5 test #1 12 3 4 1 5 0 UP, 3 DOWN test #24 UP, 2 DOWN 10 2 2 1 6 test #3 IMPOSSIBLE M 1. There is a building of “n” floors. There is an elevator in the building which has “UP” and “DOWN” buttons. By pressing the “UP” button, the elevator moves up exactly “a” floors. By pressing the "DOWN" button, the elevator moves down exactly "b" floors. If you attempt to move the elevator to lower than the first floor or higher than the "n"th floor, the elevator does not move. Now, you are in the "k" floor and want to go to the "m"th floor. Compute and print out the minimum number of times you should press the "UP" or "DOWN" buttons to go to the destination. Assume that l≤n≤ 9999. Input) The first line of the input should be the number of test cases. For each test case, a user should provide “n”, “a”, “b”, “k”, and “m” in order. Output) Print format should be "test #[testcase_number] [result] UP, [result] DOWN”, If there is no feasible solution, your program should print "IMPOSSIBLE", Sample) 3 10 1 1 8 5 test #1 12 3 4 1 5 0 UP, 3 DOWN test #24 UP, 2 DOWN 10 2 2 1 6 test #3 IMPOSSIBLE M
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
An elevator in the Taipei 101 skyscraper can start from rest and accelerate to a maximum speed of 16 m/s with a constant acceleration of 1.1 m/s2. Through what distance does the elevator move as it...
-
Consider the contour map in the figure, which has six points marked on it. Assume that points A and B correspond to summits, and that the contour lines have 40-foot intervals. Complete parts a...
-
Eight people enter an elevator in the parking garage below a building. Each person chooses her exit independently of the other people. The building has floors 1 through 10. What is the expected...
-
5 Question 42 (2.5 points) Consider a put option that gives the long position the right to sell the underlying asset for $12.34 in 5.67 years. The continuously compounded risk free rate of interest...
-
Top managers of Culinary Imports are reviewing company performance for 20X7. The income statement reports a 15% increase in net income, the fifth consecutive year showing an income increase above...
-
Suppose that 3-month, 6-month, 12-months, 2-year, and 3-year OIS rates are 2.0%, 2.5%, 3.2%, 4.5%, and 5%, respectively. The 3-month, 6-month and 12-month OISs involve a single exchange at maturity;...
-
Tennessee law imposes durational-residency requirements on persons and companies wishing to operate retail liquor stores, requiring applicants for an initial license to have resided in the state for...
-
On January 1, 2011, Adams Corporation signed a 5-year non-cancelable lease for a machine. The terms of the lease called for Adams to make annual payments of $9,968 at the beginning of each year,...
-
A young child pushes her stuffed plush cow down a frictionless slide at the playground. The slide has a height h. The cow exits the slide horizontally at the bottom. The cow slides along the level...
-
Karen Samuels (Social Security number 123-45-6789) makes the following purchases and sales of stock: Assuming that Karen is unable to identify the particular lots that are sold with the original...
-
A double replacement reaction between lead(IV) nitrate and sodium chloride will produce lead(IV) chloride and sodium nitrate. If 1.02 moles of lead(IV) nitrate is reacted, how many grams of sodium...
-
What are the different types of checks and money orders?
-
On June 18, Templeton deposited in his bank account a $5,000 check that was payable to his order. The check reached the drawee bank through normal banking channels on June 22. That bank had received...
-
What makes the U.S. dollar exchange rate fluctuate?
-
For 50 years, Cuba had a centrally planned economy in which the government makes the big decisions on how resources will be allocated. a. Why would you expect Cubas production possibilities (per...
-
Powell, intending to write a check to Thompson Electric, Inc., instead made it payable to the order of Tompson Electric. Thompson Electric, Inc., indorsed the check with its name correctly spelled....
-
Explain constitutional law and identify issues that this law addresses. Explain statutory law and identify issues that this law addresses. Explain administrative law and identify issues that this law...
-
Identify the Critical Infrastructure Physical Protection System Plan.
-
The human ear canal is much like an organ pipe that is closed at one end (at the tympanic membrane or eardrum) and open at the other (FIGURE 14-48). A typical ear canal has a length of about 2.4 cm....
-
An rms voltage of 120 V produces a maximum current of 4.1 A in a certain resistor. Find the resistance of this resistor.
-
(a) When the ac generator in FIGURE 24-34 operates at high frequency, is the rms current in the circuit greater than, less than, or the same as when the generator operates at low frequency? In figure...
-
Many hotel jobs are inherently dead end; for example, maids, laundry workers, and valets, either have no great aspirations to move up, or are just using these jobs temporarily, for instance, to help...
-
Using what you learned in this chapter of Dessler Human Resource Management, build on the companys new system by recommending two more specific career development activities the hotel should...
-
Should other employees (cleaner/spotters, counter people) be put on a similar plan? Why or why not? If so, how exactly?
Study smarter with the SolutionInn App