APT: Pancakes


Problem Statement

Consider the pancake problem in which a number of pancakes need to be cooked in the shortest time possible using only one pan. Each pancake must be cooked for five minutes on each side (once a pancake starts to fry on one side, it has to cook for five minutes, but it can be taken out of the pan between sides).

Write the method, minutesNeeded, that returns the shortest time needed to cook m pancakes in a pan that holds n pancakes at once. In other words, given two integer values, m and n, determine the smallest number of minutes needed to cook the pancakes.

Definition

Class

public class Pancakes { public int minutesNeeded (int m, int n) { // TODO: fill in code here } }

Constraints

Examples

  1. 0 4

    Returns: 0

    It takes no time to cook 0 pancakes.

  2. 2 2

    Returns: 10

    You cook both pancakes on one side for five minutes, then flip them over and cook the other side for another five minutes.

  3. 3 2

    Returns: 15

    You cook pancakes 1 and 2 on one side for five minutes, then you take pancake 2 out of the pan, flip pancake 1 and cook pancake 3. After 10 minutes, pancake 1 is done and we can then cook pancakes 2 and 3 for 5 minutes on their uncooked side