Pizzanomicón P45867


Statement
 

pdf   zip

Some fragments of the most important cookery book ever, the Pizzamonicon.

“Four are the pillars that a good pizza is founded in: the honesty of the dough, the quality of the mozzarela, the courage of the ingredients, and the wisdom of the oven.”

“Buy the raw dough of bread in a bakery, give yourself the holy shape of disk. Use a little bit of flour to avoid that it sticks. You will obtain a good dough and very, very cheap. Remember that eating frozen pizza dough is a sin.”

“Do not save money with the mozzarela, if you use mozzarela to melt, as well as if you choose mozzarela di bufala. Using cheap mozzarela is a sin.”

“Use those ingredients that can be eaten war (anchovies, cold meats, pinapple...) or those one that, cutting them thin, need a little cooking (mushrooms, bacon...) Using preserve mushrooms, being able to buy them fresh, is a sin.”

“Put the oven at maximal power. Know your oven: depending on the type of dough, its thickness, the type of oven, your pizza tray, and if you put it cold or warm on the oven, your pizza will last more or less to be done. You must discover the magic number of minutes φ\varphi that are needed to cook perfectly your pizza in your oven. Test: prepare various identical pizzas, and cook them one by one different quantities nn of minutes, until you find the exact point.”

In order to follow this last advice to the letter, I have prepared a big quantity of pizzas to cook on my barbeque. As I do not know the time that my barbeque lasts to cook a pizza, I will follow the next process:

  • I put a pizza on the barbeque.

  • I wait a number nn of minutes.

  • I remove the pizza, and wait exactly tt minutes in order to the pizza has the optimal temperature to be tasted.

  • I taste the pizza.

I last t+nt+n minutes applying these steps, in the end I will discover:

  • Pizza is perfect: n=φn = \varphi.

  • Pizza is underdone: n<φn < \varphi.

  • Pizza is burnt: n>φn > \varphi.

Assuming that I previously know that using n=an=a minutes I will obtain an underdone pizza, and that using n=bn=b minutes I will burn the pizza, discover which process I should follow to find the magic constant φ\varphi. In particular, I ask you to write a program that, given aa, bb and tt, discovers a strategy that minimizes the number of minutes MM that I will loose cooking pizzas to discover φ\varphi, in the worst situatation contemplated by the strategy. Your program must print the number of minutes that I will loose if this circunstance is given

For instance, if b=a+2b=a+2, is obvious that φ=n\varphi = n, for this reason the answer is M=0M=0. If b=a+3b=a+3, I will have to cook at least a pizza to know how many is φ\varphi, so that M=a+1+tM=a+1+t (if I have to cook a pizza, is better to try the one that lasts less time). If b=a+4b=a+4, then M=a+2+tM=a+2+t (if I chose n=a+1n=a+1 and the pizza was underdone, I would not know if the answer is φ=a+2\varphi=a+2 or φ=a+3\varphi=a+3, so that I would have to cook a second pizza). When b>a+4b>a+4, in the worst case I will have to prepare two pizzas, and the calculations are more complicated. In particular, the time tt has importance: it can be preferable to cook 2 pizzas little time than 1 pizza long time.

Input

A non empty sequence of lines, each one of them corresponds to the 3 values tt, aa and bb of a case, separated by spaces. Is is fulfilled that 0t2000\leq t\leq 200, 0a<b2000\leq a<b\leq 200 and ba>1b-a>1.

Output

Your program must print in a line for each case the number of minutes that I will last to discover φ\varphi, assuming that I follow a strategy that minimizes this number.

Public test cases
  • Input

    2 6 8
    2 6 9
    2 6 10
    2 6 11
    2 6 12
    2 6 13
    2 6 14
    2 6 15
    2 6 16
    2 6 17
    0 5 15
    10 5 15
    194 1 199
    2 1 199
    

    Output

    0
    9
    10
    20
    22
    24
    26
    33
    36
    39
    27
    57
    2232
    952
    
  • Information
    Author
    Omer Giménez
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++