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


超详细 | 贝叶斯网络基础——有图有真相 Hello,大家好,我是starz。这是本系列的第二篇《概率基础Ⅱ》,虽说是概率基础,但作为过渡,它开始以图为载体 这节的主要内容有: 贝叶斯网络 三种结构 D-划分 贝叶斯球 马尔科夫毯 应用例子 总结 让我们开始吧 :3 贝叶斯网络 概率图模型可笼统分为两类,一是基于无向图的马尔科夫网络: 二是基于有向图的贝叶斯... 阅读详情

相关推荐

(蓝桥杯)STM32G431RBT6(SysTick timer)

选用最基础的定时器。

2301_81764359的博客 1900

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

STM32开发者必看:如何在正点原子探索者开发板上快速移植CANopenNode协议栈

本文为STM32开发者提供了在正点原子探索者开发板上快速移植CANopenNode协议栈的实战指南。文章详细介绍了从环境准备、硬件抽象层适配到协议栈初始化与测试的全过程,并分享了PDO配置与性能优化等关键技巧,帮助开发者高效实现CANopen标准化通信。

weixin_29173777的博客 462

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

PyRoki 入门教程(二)安装与使用

PyRoki是一个用于机器人运动学优化的Python库,具有模块化设计、可扩展性和跨平台支持等特点。它支持逆运动学、轨迹优化和动作重定位等任务,采用Levenberg-Marquardt优化器提高效率。主要功能包括:基于URDF的可微分正向运动学模型、自动生成碰撞基元、通用成本因子和自定义成本函数等。PyRoki支持CPU、GPU和TPU运行,适用于从单机器人到大规模并行处理场景。目前存在一些限制,如仅支持软约束、静态形状和特定关节类型等。官方提供了多个应用示例,包括基础逆运动学、碰撞检测、轨迹优化和手部/

机器人控制与仿真应用 1251

【Dify(v1.x) 核心源码深入解析】File 模块

文件模型(File Model)定义了文件的核心属性,如文件类型、传输方法、相关标识符等,是整个文件处理流程的数据基础。文件解析器(UploadFileParser)负责解析上传的文件,根据配置决定以何种方式(URL 或 Base64)提供图像数据。工具文件解析器(ToolFileParser)专注于工具文件的管理,提供工具文件管理器的获取接口。签名验证与生成(helpers.py)包含文件 URL 签名的生成与验证逻辑,确保文件访问的安全性。文件管理器(file_manager.py)

668

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

垂类大模型 研发方向与具体方案调研

领域知识库加上通用大模型,针对通用大模型见过的知识比较少的问题,利用向量数据库等方式根据问题在领域知识库中找到相关内容,再利用通用大模型强大的summarization和qa的能力生成回复,完成本次垂直大模型研发。目前很多企业希望将大模型的能力应用到企业内部当中,但很多通用大模型只是一个预训练模型,其所能回答的知识主要来源于互联网上公开的通用知识库,对于部分垂直领域和企业内部的私有知识库的问答,给出的回答。:垂类大模型的效果与底座性能息息相关,研发垂类大模型第一步就是确定开源大模型解决方案。

风吹落叶的博客 3329

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

Gromacs 模拟昆虫 P450 解毒酶与农药结合完整指南,仅供参考!

🏆 本文收录于《全栈Bug调优(实战版)》专栏,致力于分享我在项目实战过程中遇到的各类Bug及其原因,并提供切实有效的解决方案。无论你是初学者还是经验丰富的开发者,本文将为你指引出一条更高效的Bug修复之路,助你早日登顶,迈向财富自由的梦想🚀!同时,欢迎大家关注、收藏、订阅本专栏,更多精彩内容正在持续更新中。让我们一起进步,Up!Up!Up!    备注: 部分问题/难题源自互联网,经过精心筛选和整理,结合数位十多年大厂实战经验资深大佬经验总结所得,数条可行方案供所需之人参考。

**My Coding Family** 1240

【WRF安装】WRF编译错误:problems building executables look for error in the build log

WRF编译错误:problems building executables look for error in the build log

WW、forever的博客 752

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

北斗导航 | 卫星信号捕获跟踪原理解析

卫星信号的捕获与跟踪是导航接收机的"眼睛",其性能直接决定定位精度、动态适应性和抗干扰能力。随着北斗三号全球组网完成,新一代接收机正朝着。两大核心阶段,二者共同构成定位的基础。调制,频谱主瓣宽度达4.092MHz,较传统BPSK调制抗干扰能力提升3dB[38]。的目标持续演进,在自动驾驶、精密农业等领域展现出巨大应用潜力。二维空间中搜索峰值相关能量[4]。卫星导航接收机对信号的处理可分为。北斗三号B1C/B2a信号采用。北斗三号新增的B1C信号采用。

尘世冰封的专栏 773

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

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

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

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

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

题目:Round #266 (Div. 2)

hongrock的专栏 589

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、付费专栏及课程。

余额充值