Question: In Java please don't use repated code Description Mysterious Gadget Description On my way to work I find an interesting device. On the device there

In Java please don't use repated code Description
Mysterious Gadget
Description
On my way to work I find an interesting device. On the device there are five large buttons:
a RED button, a GREEN button, a BLUE button,
a WHITE button and a BLACK button. There is also a LCD panel showing a non-negative integer. I notice that as soon as I turn on the the device, it sho ws a positive integer (say n).
If I click the RED button, the device will multiple the displayed number by 2.
If I click the GREEN button, the device will multiple the displayed number by 5.
If I click the BLUE button, the device will increment the displayed number by 1.
If I click the BLACK button, the device will subtract 1 from the number on the display.
If I click the WHITE button, the device will divide the displayed number by 2(integer division).
At any time if the number stops being non-negative the device goes crazy and I have to restart it. The display can show arbitrarily large numbers.
My colleague challenges me to display integer m on the display with MINIMUM number of button clicks on the device. Since we learn about trees and gr aphs this semester, I thought I'll show him what West Valley students can do by asking you to write such a program!
Note the Judge only handles console 1/0. So read from the console and write to the console
Input
The first and the only line of the input contains two distinct integers n and m (1<=n,m<=10000), separated by a space .
Output
Print a single number the minimum number of times one needs to push a button required to get the number m out of number n.
Sample Input 1 l
Sample Output 1
Sample Input 1
46
Sample Output 1(your program output)
Explanation: you need to push the BLACK button (-1) once, and then push the RED button (*2) once. Hence the answer is 2.
Sample Input 2
4122
Sample Output 2(your program output)
3
Explanation: You need to press WHITE, BLUE, BLUE to get 4
1-20-21-22. Hence the answer is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!