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

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

备战无人机配送:互联网派To C、技术派To B

cache2go-源码阅读

微服务-gateway【服务网关入门】

VSTO踩坑记录(1)- 从零开始开发outlook插件

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

Functional test points for time, here is a comprehensive summary for you

sed 命令

【动态规划专项训练】基础篇

LeetCode 2349. 设计数字容器系统(SortedSet)
随机推荐
cache2go-源码阅读
From the technical panorama to the actual scene, analyze the evolutionary breakthrough of "narrowband high-definition"
荐号 | 当一个人不联系你,不拉黑你,原因只有一个……!
7.24 - 每日一题 - 408
安装Mac版Mysql卡在Installation阶段,彻底清理mysql并重装mysql
MySQL主从搭建(问题大聚集,告别部署烦恼)
回收站删除的文件怎么恢复,2个方法汇总助您快速解决
Mobile Banking Experience Test: How to Get the Real User Experience
洛谷P2880 Balanced Lineup G
快手web did可用生成
千万级别的表分页查询非常慢,怎么办?
编译型语言与解释型语言的区别
LeetCode 2349. 设计数字容器系统(SortedSet)
喜迎八一 《社会企业开展应聘文职人员培训规范》团体标准出版发行会暨橄榄枝大课堂上线发布会在北京举行
二本 两年经验读者 阿里P6面经
mongodb的游标
日常开发中,String类中常用的方法
衡量软件产品质量的 14 个指标
说一件事
大事务故障案例