A.Cheap Travel

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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值