Pizzanomicón P45867


Statement
 

pdf   zip

html

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 ϕ that are needed to cook perfectly your pizza in your oven. Test: prepare various identical pizzas, and cook them one by one different quantities n 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 n of minutes.
  • I remove the pizza, and wait exactly t minutes in order to the pizza has the optimal temperature to be tasted.
  • I taste the pizza.

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

  • (1) Pizza is perfect: n = ϕ.
  • (2) Pizza is underdone: n < ϕ.
  • (3) Pizza is burnt: n > ϕ.

Assuming that I previously know that using n=a minutes I will obtain an underdone pizza, and that using n=b minutes I will burn the pizza, discover which process I should follow to find the magic constant ϕ. In particular, I ask you to write a program that, given a, b and t, discovers a strategy that minimizes the number of minutes M that I will loose cooking pizzas to discover ϕ, 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+2, is obvious that ϕ = n, for this reason the answer is M=0. If b=a+3, I will have to cook at least a pizza to know how many is ϕ, so that M=a+1+t (if I have to cook a pizza, is better to try the one that lasts less time). If b=a+4, then M=a+2+t (if I chose n=a+1 and the pizza was underdone, I would not know if the answer is ϕ=a+2 or ϕ=a+3, so that I would have to cook a second pizza). When b>a+4, in the worst case I will have to prepare two pizzas, and the calculations are more complicated. In particular, the time t 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 t, a and b of a case, separated by spaces. Is is fulfilled that 0≤ t≤ 200, 0≤ a<b≤ 200 and ba>1.

Output Your program must print in a line for each case the number of minutes that I will last to discover ϕ, 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++