当前位置:网站首页>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;
}
}
}
}
边栏推荐
猜你喜欢
Golang swagger :missing required param comment parameters
微服务-gateway【服务网关入门】
Win11dll文件缺失怎么修复?Win11系统dll文件丢失的解决方法
有哪些好用的实时网络流量监控软件
[Dynamic Programming Special Training] Basics
Sentinel vs Hystrix 限流对比,到底怎么选?
MySQL详细安装与配置
【C语言刷题】Leetcode169——多数元素
Mppt photovoltaic maximum power point tracking control matlab simulation
Sentienl【动态数据源架构设计理念与改造实践】
随机推荐
Sentinel vs Hystrix 限流对比,到底怎么选?
小姐姐面试蚂蚁金服被虐经历,心疼...
大事务故障案例
Mysql基础篇(视图)
元旦快乐(2022)
What are the useful real-time network traffic monitoring software
固态硬盘接口类型介绍
WPF login with Prism
From the technical panorama to the actual scene, analyze the evolutionary breakthrough of "narrowband high-definition"
LeetCode 2349. 设计数字容器系统(SortedSet)
Technical life | How to draw a big picture of business
register和volatile的区别
指针常量和常量指针概述
连续三次 | 灵雀云入选Gartner中国ICT技术成熟度曲线报告
流量分析三—远程登陆
Why young people are snapping up domestic iPhone, because it is much cheaper and more populist
JVM内存和垃圾回收-06.本地方法栈
7.21 - 每日一题 - 408
MySQL主从搭建(问题大聚集,告别部署烦恼)
CWE4.8:2022年危害最大的25种软件安全问题