Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.

book
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

main.cpp

C++

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt