Codeforces Round #381 (Div. 2) A Alyona and copybooks

Intel AX系列网卡5G热点开启失败?Linux下3种修复方案实测(含Ubuntu/OpenWRT) 本文针对Intel AX系列网卡在Linux系统下无法开启5G热点的常见问题,深入剖析了其根源在于内核LAR机制与驱动的兼容性。文章提供了三种实测有效的修复方案:针对内核低于5.5的模块参数法、适用于高内核版本的hostapd补丁编译法以及高阶的驱动修改法,帮助用户在Ubuntu、OpenWRT等环境中成功启用5G热点功能。 阅读详情

A. Alyona and copybooks
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for a rubles, a pack of two copybooks for b rubles, and a pack of three copybooks for c rubles. Alyona already has n copybooks.

What is the minimum amount of rubles she should pay to buy such number of copybooks k that n + k is divisible by 4? There are infinitely many packs of any type in the shop. Alyona can buy packs of different type in the same purchase.

Input

The only line contains 4 integers n, a, b, c (1 ≤ n, a, b, c ≤ 109).

Output

Print the minimum amount of rubles she should pay to buy such number of copybooks k that n + k is divisible by 4.

Examples
input
1 1 3 4
output
3
input
6 2 1 1
output
1
input
4 4 4 4
output
0
input
999999999 1000000000 1000000000 1000000000
output
1000000000
Note

In the first example Alyona can buy 3 packs of 1 copybook for 3a = 3 rubles in total. After that she will have 4 copybooks which she can split between the subjects equally.

In the second example Alyuna can buy a pack of 2 copybooks for b = 1 ruble. She will have 8 copybooks in total.

In the third example Alyona can split the copybooks she already has between the 4 subject equally, so she doesn't need to buy anything.

In the fourth example Alyona should buy one pack of one copybook.


枚举所有可能取的情况

#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
	long long int a,b,c,n,sum;
	scanf("%lld %lld %lld %lld",&n,&a,&b,&c);
	if(n%4==0)
	{
		sum=0;
	}
	else
	{
		if(n%4==1)
		{
			sum=min(a*3,c); 
			sum=min(sum,a+b);
		} 
		else if(n%4==2)
		{
			sum=min(a*2,b);
			sum=min(sum,c*2);
		}
		else if(n%4==3)
		{
			sum=min(a,b+c);
			sum=min(sum,3*c);
		}
	}
	printf("%lld\n",sum);
	return 0;
}

还有一种做法,三个for循环,纯暴力就好



Ubuntu Server 24.04 安装 (超详细) 本文介绍最小化安装 Ubuntu Server的详细过程。 阅读详情

相关推荐

【本体】Protege高效批量导入实例(Individuals)的自动化实践

本文详细介绍了在Protege中高效批量导入实例(Individuals)的自动化实践方法。通过分析Protege本体文件结构,提供Python脚本示例,帮助用户快速处理大规模数据导入,显著提升知识图谱构建效率。特别适合需要处理数千个实例的医疗、制药等领域应用。

weixin_30275415的博客 408

A. Alyona and copybooks--思维水题

A. Alyona and copybooks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little girl Alyona is in a shop to b

bless295的博客 976

Cisco Packet Tracer实战:三层交换机链路聚合配置全流程(附常见错误排查)

本文详细解析了在Cisco Packet Tracer环境中配置三层交换机链路聚合的全流程,包括基础网络设置、LACP协议配置、路由协议集成及高级优化技巧。通过实战案例和常见错误排查指南,帮助网络工程师和CCNA备考学员掌握这一提升带宽利用率和实现链路冗余的核心技术。

grafana6viz的博客 228

Alyona and copybooks

Alyona and copybooks CodeForces - 740A  Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of t

七九河开的博客 334

DeepSeek API调用太复杂?OneAPI一站式聚合解决方案

本文介绍了OneAPI如何作为一站式聚合解决方案,简化DeepSeek API的调用流程。通过统一接口、智能路由和模型映射等核心功能,OneAPI大幅降低了多API适配的复杂性,提升开发效率。文章还提供了详细的部署指南和高阶使用技巧,帮助开发者快速实现API聚合管理。

weixin_27215337的博客 381

TSMC 40nm LP工艺下,新手画版图最容易踩的5个坑(附Cadence避坑指南)

本文详细解析了TSMC 40nm LP工艺下版图设计的5个常见陷阱,包括MOS管尺寸转换、DNW隔离、Guard Ring设计、金属布线和DRC检查。通过Cadence实战技巧和设计规则优化,帮助新手工程师规避典型错误,提升版图设计效率和质量。

weixin_26800111的博客 457

acm Alyona and copybooks 新人水题

Description Little girl Alyona is in a shop to buy some copybooks forschool. She study four subjects so she wants to have equal numberof copybooks for each of the subjects. There are three types

tuchong5的博客 377

STM32F4系列HAL库配置定时器实验——输入捕获

STM32F4系列HAL库配置定时器实验——输入捕获 输入捕获简单讲解 输入捕获模式可以用来测量脉冲宽度或者测量频率。我们以测量周期和频率为例,用一个简图来说明输入捕获的原理 假定定时器工作在向上计数模式, 图中 t1~t2 时间,就是我们需要测量的高电平时间。测量方法如下:首先设置定时器通道 x 为 上升沿捕获,这样,t1 时刻,就会捕获到当前的 CNT 值,然后立即清零 CNT,并设置通道 x为下降沿捕获,这样到 t2 时刻,又会发生捕获事件,得到此时的 CNT 值,记为 CCRx2。这样,根据定时器

azs0504的博客 9286

CodeForces 740A - Alyona and copybooks

A. Alyona and copybooks time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Little girl Alyona is in a shop to buy some copybooks for school. She s...

stanmae的博客 267

sec_uid

webcast_uid转sec_uid,webcast_uid转uid,webcast_uid转dy号

m0_56967679的博客 4420

30. 如何使用 SEGW 的 redefine 功能对 SAP 标准 OData 服务进行扩展

SAP 发布了很多标准的 Fiori 应用,可以通过笔者的文章里提到的进行浏览。比如 My Opportunities 就是 SAP CRM 领域的一个 Fiori 应用:下图是 Opportunity 明细页面的 Info 标签页:假设我们想在这些标准字段的末尾增添一个新字段 Created By,用来维护当前 Opportunity 的创建者。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1171

Codeforces Round #381 (Div. 2) A. Alyona and copybooks(模拟)

A. Alyona and copybooks time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Little girl Alyona is in a shop to buy some copybooks for school. S

Prim 511

通过傅里叶变换进行音频变声变调

在游戏或者一些特殊场景下为了提高娱乐性或者保护声音的特征,我们会对音频进行变声变调处理。

yang1fei2的博客 1815

Codeforces Round #381 (Div. 2) A.Alyona and copybooks

time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so

=_= 370

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Codeforces Round #381 (Div. 2) A. Alyona and copybooks

http://codeforces.com/problemset/problem/740/A 题意: 给出四个数据n、a、b、c,其中a、b、c、分别代表补一、补二、补三的花费,问用补一、补二、补三的方法将数据n补成4的倍数所需的最少花费。 代码: #include #include using namespace std; long long n,a,

学 以致用 277

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Codeforces Round #381 (Div. 2) A - Alyona and copybooks(思维)

题目链接 题意: 现有n个本子,现需买k个本子使n+k被4整除。其中有三种方案: (1)花费a购买一个本子 (2)花费b购买两个本子 (3)花费c购买三个本子 最少需要花费多少钱购买k个本子使n+k被4整除。 思路: n对4取余,得到最少需要的个数。余数为0时,不需要再购买;余数为1时,最少需要购买3个,可行的方案: (1)花费3a ,得到3个 (2)花费a+b,得到3个 (3)花费c,得到3个,同样被4整除 上面三种包含了所有花费最低的方案,也可以花费b+c,3a+c等,同样n+k被4整除,但花费比上面三

qq_46667619的博客 175

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Codeforces Round #381 (Div. 2)A. Alyona and copybooks(dfs)

A. Alyona and copybooks Problem Description: Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each ...

weixin_30596343的博客 132

Codeforces Round #381 (Div. 2) A. Alyona and copybooks(思维)

题目链接:http://codeforces.com/contest/740/problem/A【中文题意】买一本书需要花费a元,买两本书需要花费b元,买三本书需要花费c元。现在你有n本书,问你至少要花费多少元能拥有4的倍数本书。 【思路分析】首先假如n是3,要构成4的倍数本书有很多种情况,例:再买一本书,再买5本书。5可以有2和3构成,然后取最小值。所以呢,先暴力求一发买4*k+1本书的最小花费

linlinsong—ACM界蒟水! 342

Codeforces 740A Alyona and copybooks

http://codeforces.com/contest/740/problem/A A. Alyona and copybooks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard out

Shyazhut 613

A.Alyona and copybooks

这题考查思维的全面性。 一开始我直接分类推公式,余数不同分类讨论。 AC代码: #include<cstdio> #include<algorithm> using namespace std; typedef long long LL; const LL inf=1e12; int main(){ LL ans=inf; LL n,a,b,c; scanf...

weixin_30770495的博客 151

CodeForces-740A (分类)

题目: http://codeforces.com/problemset/problem/740/A 题意: 给定n, a, b, c 分别表示: 目前已经买了n本书 书的价格:a元可买1本书,b元可买2本书,c元可买3本书 求ans(ans的含义为:用ans元,再买k本书,使得 (n + k) % 4==0 的最小 ans) 分析: 如果n已经是4的倍数,那

怕什么真理无穷?进一寸有一寸的欢喜~ 518

二分水题

When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion.  When a thin rod is mounted on two solid walls and then heated,

楚天千里清秋,水随天去秋无际 601

Codeforces 740 B Alyona and flowers(前缀和)

题目地址:http://codeforces.com/contest/740/problem/B 题意:我也看不懂,太长了,看别人博客发现就是求给定区间和的最大值(某些区间可以不选) 思路:求前缀和,然后计算每个区间和,如果和>0的话就加上。

不要錯過才珍惜 474

阿狸的纸杯蛋糕

笨狸 878

B. Alyona and a Narrow Fridge

题目链接 Alyona has recently bought a miniature fridge that can be represented as a matrix with h rows and 2 columns. Initially there is only one shelf at the bottom of the fridge, but Alyona can install ...

王小平 757

codeforces #260 DIV 2 C题Boredom(DP)

题目地址:http://codeforces.com/contest/456/problem/C 脑残了。。DP只DP到了n。。应该DP到10w+的。。 代码如下: #include #include #include #include #include #include #include #include #include #include #include usi

scf0920 2319
上一篇: Codeforces Round #380 (Div. 2,Based on Technocup 2017 - Elimination Round 2)C - Road to Cine//
下一篇: Codeforces Round #381 (Div. 2)C - Alyona and mex
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值