302418: CF466A. Cheap Travel

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Cheap Travel

题意翻译

Ann需要搭n次地铁。她有两种票可供选择:第一种票a卢布一张,可以搭一次地铁;第二种票b卢布一张,可以搭m次地铁。问:Ann最少需要多少卢布才能搭n次地铁? 输入:一行四个整数:n,m,a,b。 输出:一行一个整数:Ann搭n次地铁最少需要的钱数(以卢布为单位) 输入输出样例1解释:买六张第一种票或买三张第二种票,等等(译者注:都需要6卢布)。

题目描述

Ann has recently started commuting by subway. We know that a one ride subway ticket costs $ a $ rubles. Besides, Ann found out that she can buy a special ticket for $ m $ rides (she can buy it several times). It costs $ b $ rubles. Ann did the math; she will need to use subway $ n $ times. Help Ann, tell her what is the minimum sum of money she will have to spend to make $ n $ rides?

输入输出格式

输入格式


The single line contains four space-separated integers $ n $ , $ m $ , $ a $ , $ b $ ( $ 1<=n,m,a,b<=1000 $ ) — the number of rides Ann has planned, the number of rides covered by the $ m $ ride ticket, the price of a one ride ticket and the price of an $ m $ ride ticket.

输出格式


Print a single integer — the minimum sum in rubles that Ann will need to spend.

输入输出样例

输入样例 #1

6 2 1 2

输出样例 #1

6

输入样例 #2

5 2 2 3

输出样例 #2

8

说明

In the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three $ m $ ride tickets.

Input

题意翻译

Ann需要搭n次地铁。她有两种票可供选择:第一种票a卢布一张,可以搭一次地铁;第二种票b卢布一张,可以搭m次地铁。问:Ann最少需要多少卢布才能搭n次地铁? 输入:一行四个整数:n,m,a,b。 输出:一行一个整数:Ann搭n次地铁最少需要的钱数(以卢布为单位) 输入输出样例1解释:买六张第一种票或买三张第二种票,等等(译者注:都需要6卢布)。

加入题单

算法标签: