当前位置:网站首页>E - Addition and Multiplication 2(贪心)
E - Addition and Multiplication 2(贪心)
2022-08-02 18:41:00 【Harris-H】
E - Addition and Multiplication 2(贪心)
先可以确定位数。
然后从前到后按位,从9到1枚举放那个,特判一下后面是否能放完即可。
#include<iostream>
using namespace std;
int N,C[10];
main()
{
cin>>N;
int mC=1e9;
for(int i=1;i<=9;i++)
{
cin>>C[i];
mC=min(mC,C[i]);
}
int keta=N/mC;
for(int i=0;i<keta;i++)
{
for(int j=9;j>=1;j--)
{
int rest=N-C[j];
if(rest>=0&&rest/mC>=keta-i-1)
{
cout<<j;
N-=C[j];
break;
}
}
}
}
边栏推荐
猜你喜欢

LeetCode 2349. 设计数字容器系统(SortedSet)

视频隐写一

什么是会话劫持以及如何阻止它

leetcode:622. 设计循环队列【循环队列板子】

3 and a half years of testing experience, I don't have 20K, it seems it's time to change jobs

衡量软件产品质量的 14 个指标

TSF微服务治理实战系列(一)——治理蓝图

开源一夏 | Web开发(七):登录实现及功能测试

What are the useful real-time network traffic monitoring software

针对时间的功能测试点,这里给你总结全面了
随机推荐
selenium安装和环境配置Firefox
监控易火星版即将亮相:分布式运维帮助TOP3000大企业跨越管理鸿沟
From the technical panorama to the actual scene, analyze the evolutionary breakthrough of "narrowband high-definition"
How to build a quasi-real-time data warehouse?
流量分析第一题
LeetCode 2343. 裁剪数字后查询第 K 小的数字
7.22 - 每日一题 - 408
看【C语言】实现简易计算器教程,让小伙伴们为你竖起大拇指
【软考软件评测师】基于经验的测试技术
洛谷P1966 火柴排队
[Dynamic Programming Special Training] Basics
洛谷P2880 Balanced Lineup G
安装Mac版Mysql卡在Installation阶段,彻底清理mysql并重装mysql
Win11主题下载一直转圈怎么办?Win11主题下载一直转圈的解决方法
Monitor is easy to Mars debut: distributed operations help TOP3000 across management gap
Mysql基础篇(视图)
大事务故障案例
互联网寒冬,挚友7面阿里,终获Offer
电子行业库存管理痛点与WMS仓储管理系统解决方案
pydev debugger: warning: trying to add breakpoint to file that does not exist: /tmp/xxx