CF466A.Cheap Travel

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

输入格式

The single line contains four space-separated integers nn , mm , aa , bb ( 1<=n,m,a,b<=10001<=n,m,a,b<=1000 ) — the number of rides Ann has planned, the number of rides covered by the mm ride ticket, the price of a one ride ticket and the price of an mm 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 mm ride tickets.

首页