Codeforces Round #266 (Div. 2) A

travellier:旅行行程申请表,用于计划您的所有行程 由团队创建的用生成的Rails应用程序。 立即下载

题目:

A. Cheap Travel
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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?

Input

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.

Output

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

Sample test(s)
input
6 2 1 2
output
6
input
5 2 2 3
output
8
Note

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.

题意分析:

很简单的贪心,但是边缘数据和取整注意细节。

代码:

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <numeric>


using namespace std;


int main()
{
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    double f = (double)b/(double)m;
    if (f < (double)a)
    {
        int k1 = n/m;
        int k2 = n-k1*m;
        int k3 = (k1+1)*b;
        cout << min(k1*b+k2*a, k3);
    }
    else
    {
        cout << n*a << endl;
    }
    return 0;
}


EXI编解码避坑指南:ISO15118-2协议中3条异常命令的差异分析 本文深度剖析了ISO15118-2协议测试中EXI编解码的典型问题,聚焦于ChargeParameterDiscoveryRes、CertificateInstallationReq和MeteringReceiptReq三条命令在不同工具间产生109字节差异的现象。通过对比EXICodec.jar、OpenEXI和Efficient XML的输出,揭示了差异根源于EXI报头处理机制与模式文件完整性,并提供了从现象确认、根因分析到解决方案的标准化排查流程,助力协议测试工程师确保编解码一致性与通信可靠性。 阅读详情

相关推荐

VC中基于TWAIN协议控制扫描仪-----初级版

PS:本人是C++小白一枚,在研究此功能时不知走了多少弯路

a1101000099的专栏 8789

Codeforces 1447 A题

Codeforces 1447 A. Add Candies time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output 题目描述: There are ???? bags with candies, initially the ????-th bag contains ???? candies. You want all the bags to contai

qq_45654671的博客 419

Win10系统蓝屏错误BAD SYSTEM CONFIG INFO的解决方案

BAD SYSTEM CONFIG INFO错误是Win10系统中较为常见的一种蓝屏错误,通常与系统配置文件损坏或丢失有关。本文介绍了三种有效的解决方法:使用系统修复高级选项修复、通过PE修复文件和重装新系统。用户可以根据实际情况选择合适的方法进行操作。同时,建议用户定期备份系统重要文件和数据,以防止类似问题的发生。在遇到问题时,保持冷静并耐心操作,通常可以顺利解决问题。

mmoo_python的博客 7723

Cheap Travel(暴力求解法)

A. Cheap Travel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ann has recently started commuting by subway

路漫漫 始于足下 2276

[GXYCTF2019]BabyUpload1 -- .htaccess文件解析与蚁剑实战指南

本文深入解析了[GXYCTF2019]BabyUpload1文件上传漏洞的实战利用。通过绕过后缀名与内容检测,上传包含PHP代码的.jpg文件,并利用.htaccess文件强制服务器将其解析为PHP脚本。文章详细介绍了.htaccess的原理、构造方法、Content-Type绕过技巧,并演示了如何使用中国蚁剑连接Webshell获取Flag,为Web安全学习提供了完整实战指南。

weixin_29016315的博客 509

保姆级避坑指南:Mid-360雷达到手后,用livox_ros_driver2从接线到出点云的完整流程

本文提供Mid-360雷达到手后的完整使用指南,涵盖从硬件接线、网络配置到livox_ros_driver2驱动的安装与调试,帮助用户避开常见陷阱,实现点云数据的稳定输出与可视化。重点解析了配置文件的参数设置和点云格式选择,确保用户能够高效部署和使用Mid-360雷达。

weixin_30733003的博客 484

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 subw

qq_36536255的博客 376

实战二:基于LightGBM进行海洋轨迹预测 代码+数据(非常详细可作为毕设)

实战二:基于LightGBM进行海洋轨迹预测 代码+数据(非常详细可作为毕设)

1315

A. Cheap Travel

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 u

Erin_jwx的博客 308

在实车上进行lio-sam测试

PS:将雷达和imu相对固定后,拆下来,原地晃啊晃,直到xyz进度达到百分百,参考gif。标定完成后,会在result文件夹下生成result.txt。

如果想成为中心,那么就到中心去吧。 997

多智能体强化学习算法【三】【QMIX、MADDPG、MAPPO】

相关文章: 1.QMIX算法简述 QMIX是一个多智能体强化学习算法,具有如下特点: 1. 学习得到分布式策略。 2. 本质是一个值函数逼近算法。 3. 由于对一个联合动作-状态只有一个总奖励值,而不是每个智能体得到一个自己的奖励值,因此只能用于合作环境,而不能用于竞争对抗环境。 4. QMIX算法采用集中式学习,分布式执行应用的框架。通过集中式的信息学习,得到每个智能体的分布式策略。 5. 训练时借用全局状态信息来提高算法效果。是后文提到的VDN方法的改进。 6. 接上一条,QMIX设计一个神经网络来

丨汀、的博客 5471

Codeforces Round #266 (Div. 2) A. Cheap Travel

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

那些年 2133

华为OD机试真题 新系统2026-04-08 Python&JS 实现【直捣黄龙】

小王在玩一款叫做直捣黄龙的小游戏,在该游戏中他需要从入口位置进入敌营,绕过哨兵的层层封锁,达到敌军司令部实施斩首行动。 敌军阵营是一个n*n的矩阵,入口在坐标(0,n/2),敌军司令部在坐标(n-1,n/2),每个哨兵警戒以自己为中心的9宫格,一旦被哨兵发现则行动失败。

MISAYAONE的博客 587

Codeforces Round #266 (Div. 2) A. Cheap Travel

A. Cheap Travel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ann has recently started commuting by subway

在风雨中奔跑 714

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Codeforces Round #266 (Div. 2)

A. Cheap Travel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ann has recently started commuting by subway

逍遥小章 1068

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Codeforces Round #266 (Div. 2)(解题报告)

题目:Round #266 (Div. 2)

hongrock的专栏 589

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Codeforces Round #266 (Div. 2) B. Wonder Room

B. Wonder Room time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The start of the new academic year brought ab

ShiAokai 1032

Codeforces Round #266 (Div. 2) C

C. Number of Ways 题意:一个数列

A Cube Master 533

Codeforces Round #163 (Div. 2) 266D BerDonalds

题意: 在图上找一个点为源点,这个点可以在边上或者顶点上。使得以这个点为源点的最短路中的最大值是最小的,求这个最小值。 思路: 这题搞了好久。。。请教了宁神才懂。我们先Floyd求出所有最短路。源点肯定实在某条边上或者边的端点上,所以枚举所有边。每次枚举边的时候我们这样求出此时的最大值:            设边两端点为u,v。我们把所有点分成两部分,某些是从u端延伸出去找到的,某些

new Blog("gzh") 1002

Codeforces Round #266 (Div. 2)C(算是简单计数吧)

C. Number of Ways time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You've got array a[1], a[2], ..., a[n], c

cq_phqg 938

Codeforces Round #266 (Div. 2)解题报告

http://codeforces.com/contest/466

ACM,再见! 820

【索引】Codeforces Round #266 (Div. 2)

Problem B: Jzzhu and Sequences(450B) Problem C:Jzzhu and Chocolate(449A) Problem D: Jzzhu and Cities(449B) Problem E:Jzzhu and Apples(449C)

不慌不忙、不急不躁 936
上一篇: 快速幂小模板
下一篇: hdu 2817 A sequence of numbers
Notdeep__acm
博客等级 码龄12年 20粉丝 53原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值