Optimizing Tomato Purchases
The price of one tomato at grocery-store is a dollars, but there is a promotion where you can buy two tomatoes for b dollars. Bob needs to buy exactly n tomatoes. When buying two tomatoes, he can choose to buy them at the regular price or at the promotion price.
What is the minimum amount of dollars Bob should spend to buy n tomatoes?
Example 1
Input:
n = 2; a = 5; b = 9
Output:
9
Example 2
Input:
n = 3; a = 5; b = 11
Output:
15
main.cpp
C++
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat