当前位置:网站首页>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;
}
}
}
}
边栏推荐
猜你喜欢

CWE4.8:2022年危害最大的25种软件安全问题

Why young people are snapping up domestic iPhone, because it is much cheaper and more populist

“12306”的架构到底有多牛逼?

From the technical panorama to the actual scene, analyze the evolutionary breakthrough of "narrowband high-definition"

Jupyter Notebook(Anaconda)——两个环境分别修改默认打开目录(深度学习第一周番外篇)

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

下载mysql的源码包

【C语言刷题】Leetcode169——多数元素

视频隐写一

Sentienl【动态数据源架构设计理念与改造实践】
随机推荐
NIO之Selector执行流程
MySQL主从搭建(问题大聚集,告别部署烦恼)
下载mysql的源码包
荐号 | 当一个人不联系你,不拉黑你,原因只有一个……!
实例033:列表转字符串
平稳发展 | 西欧地区手游玩家的数据和洞察
Golang swagger :missing required param comment parameters
什么是会话劫持以及如何阻止它
LeetCode 1947. 最大兼容性评分和(状态枚举DP)
What skills are the most practical for college students in communications?
有什么好用的IT资产管理软件
AI智能剪辑,仅需2秒一键提取精彩片段
arcgis 分子式标注
js Fetch返回数据res.json()报错问题
针对时间的功能测试点,这里给你总结全面了
CWE4.8:2022年危害最大的25种软件安全问题
去年,一道蚂蚁金服笔试题,还行,中等难度
WPF使用Prism登录
Three components of NIO foundation
T5: Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer