CF466A.Cheap Travel

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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?

安娜最近开始乘坐地铁通勤。已知单程地铁票的价格为 aa 卢布。此外,安娜发现她可以购买一种特殊车票,每张可乘坐 mm 次(她可以购买多张),每张售价为 bb 卢布。安娜已计算出自己总共需要乘坐地铁 nn 次。请帮助安娜计算:她完成这 nn 次乘车所需的最少花费是多少?

输入格式

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.

单行包含四个以空格分隔的整数 nn、mm、aa、bb(1 ≤ n, m, a, b ≤ 10001 ≤ n, m, a, b ≤ 1000)——分别表示安计划乘坐的次数、mm 次票所覆盖的乘坐次数、单次票的价格以及 mm 次票的价格。

输出格式

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

输出一个整数——Ann 需要花费的最少金额(单位:卢布)。

输入输出样例

  • 输入#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.

在第一个样例中,一种最优解是:每次购买一张单程票。也存在其他最优解,例如购买三张 mm 次票。

输入解题思路,AI测评打分。不知道怎么写?

首页