Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Ми дуже хвилюємося, що щось пішло не так. Що трапилося?

book
Bob's Bus Ticket Problem

Bob has recently started commuting by bus. We know that a one bus ride ticket costs a dollars. Besides, Bob found out that he can buy a special ticket for m rides, also he can buy it several times. It costs b dollars. Bob will need to use bus n times. Help Bob to calculate what is the minimum sum of money he will have to spend to make n rides?

Example 1

Input:

n = 10; m = 3; a = 1; b = 2

Output:

7

Example 2

Input:

n = 10; m = 2; a = 1; b = 1

Output:

5
main.cpp

main.cpp

cpp

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

some-alt