AtCoder Beginner Contest 251
比赛链接
AtCoder Beginner Contest 251
D - At Most 3 (Contestant ver.)
Problem Statement
You are given an integer .
You are going to prepare some weights so that all of the conditions below are satisfied.
- The number of weights is between 1 and 300 , inclusive.
- Each weight has a mass of positive integer not exceeding .
- Every integer between 1 and , inclusive, is a good integer. Here, a positive integer is said to be a good integer if the following condition is satisfied:
-
- We can choose at most 3 different weights from the prepared weights with a total mass of .
Print a combination of weights that satisfies the conditions.
Constraints
- is an integer.
解题思路
思维,构造
构造这样一些数:
个:
个:
个:
共 个数
显然,一和二位的数已经存在,对于三位的数,可用 和 组合,故可用 个数得到三位数,此时存在的四位数为 ,可以 与这些数组合得到任意四位数,即可用 个数得到四位数,此时存在的五位数为 ,可用四位数与其组合成任意五位数,即可用 个数得到五位数,另外, 可用 和 得到
- 时间复杂度:
代码
__EOF__

本文作者:acwing_zyy
本文链接:https://www.cnblogs.com/zyyun/p/16271725.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
本文链接:https://www.cnblogs.com/zyyun/p/16271725.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!