A.Cheap Travel
A.Cheap旅行
time limit per test: 1 second
每次测试的时间限制:1秒
memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节
input: standard input
输入:标准输入
output: standard output
产出:标准产出
Ann has recently started commutng by subway.We know that a one ride subway ticket costs a rubles.Besides, Ann found out that she can
安最近开始换乘地铁,我们知道一张地铁车票要花一卢布,而且,安发现她可以
buy a specialtcket for m rides (she can buy itseveral times). lt costs b rubles.Ann did the math; she will need to use subway nt times.Help
buy a specialtcket for m rides (she can buy itseveral times). lt costs b rubles.Ann did the math; she will need to use subway nt times.Help
Ann, tell her what is the minimum sum of money she will have to spend to make n rides?
Ann, tell her what is the minimum sum of money she will have to spend to make n rides?
lnput
输入
The single line contains four space-separated integers n,m, a,b(1≤7,m,a,b≤1000)-the number of rides Ann has planned, the
单行包含四个空格分隔的整数n,m,a,b(1≤7,m,a,b≤1000)
number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket.
number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket.
output
输出量
*** 贪心***
int main() {
int n, m, a, b;
cin>>n>>m>>a>>b;
int k = n / m, ans = 0;
ans = k * m * a< k * b? k * m * a : k* b;
k = n % m;
ans += min(k * a, b);
cout<<ans<<endl;
return 0;
}