Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 7.00

dwarf city of Moria

Gandalf is fighting a Balrog in abandoned dwarf city of Moria.
Unfortunately he doesn't have much time and want to end fight as soon as possible.
As Gandalf is poor in maths you have to help him in forming the strategy.
Balrog has power which is denoted by a number X. Gandalf has three types of weapon
first one can reduce the power of Balrog to half, another weapon reduces Balrog's
power to one third of the current power. The last weapon only reduces Balrog's power
by decrementing it by one.
To kill Balrog, Gandalf has to reduce his total power to zero by using minimum number of strike.

 

Input

 

The first line of input contains a integer T which denotes the number to test cases.
After which T lines follows. Every line contains an integer X which denote the initial power of Balrog.

 

Output

 

For every test case output a integer in a new line which denotes the minimum number of strikes required to kill Balrog.

 

Input Constrain:

1

Example:

Input: 2 10 19 Output: 4 5

Explanation:

In 1st test case:
First use weapon which reduce power by 1. Then use weapon which reduce power to one third twice.
Then again the weapon which reduce power by 1.
10-1=9
9/3=3
3/3=1
1-1=0

Answers

(5)
Status NEW Posted 17 Sep 2017 05:09 AM My Price 7.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)