HDU 1085-Holding Bin-Laden Captive!(生成功能)

HDU 1085-Holding Bin-Laden Captive!(生成功能)

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

Holding Bin-Laden Captive!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 15384    Accepted Submission(s): 6892




Problem Description
We all know that Bin-Laden is a notorious terrorist, and he has disappeared for a long time. But recently, it is reported that he hides in Hang Zhou of China! 

“Oh, God! How terrible! ”


HDU 1085-Holding Bin-Laden Captive!(生成功能)

Don’t be so afraid, guys. Although he hides in a cave of Hang Zhou, he dares not to go out. Laden is so bored recent years that he fling himself into some math problems, and he said that if anyone can solve his problem, he will give himself up! 

Ha-ha! Obviously, Laden is too proud of his intelligence! But, what is his problem?

“Given some Chinese Coins (硬币) (three kinds– 1, 2, 5), and their number is num_1, num_2 and num_5 respectively, please output the minimum value that you cannot pay with given coins.”
You, super ACMer, should solve the problem easily, and don’t forget to take $25000000 from Bush!

 


Input
Input contains multiple test cases. Each test case contains 3 positive integers num_1, num_2 and num_5 (0<=num_i<=1000). A test case containing 0 0 0 terminates the input and this test case is not to be processed.

 


Output
Output the minimum positive value that one cannot pay with given coins, one line for one case.

 


Sample Input
   
   
1 1 3 0 0 0

 


Sample Output
   
   
4
仍旧是母函数水过。
题意:有3种面值的硬币{1,2,5} 如今给出这3种硬币的个数,求最小不能组成的面值。

暴力生成 a[]数组扫一遍第一个为0的就是最小不能组成的面值
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#define maxn 100100
#define ll long long
#define INF 0x3f3f3f3f
#define pp pair<int,int>
using namespace std;
int a[maxn],b[maxn],v[3]={1,2,5},p,n[3];
void solve()
{
	p=n[0]+n[1]*2+n[2]*5;
	memset(a,0,sizeof(a));
	a[0]=1;
	for(int i=0;i<3;i++)
	{
		memset(b,0,sizeof(b));
		for(int j=0;j<=n[i]&&j*v[i]<=p;j++)
			for(int k=0;k+j*v[i]<=p;k++)
			b[k+j*v[i]]+=a[k];
		memcpy(a,b,sizeof(b));
	}
	int ans;
	for(ans=0;ans<=p;++ans)
		if(a[ans]==0)break;
	printf("%d\n",ans);
}
int main()
{
	while(~scanf("%d%d%d",&n[0],&n[1],&n[2]))
	{
		if(!n[0]&&!n[1]&&!n[2])break;
		solve();
	}
	return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116966.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 深入浅出理解卷积运算

    深入浅出理解卷积运算提起卷积运算相信大家都不陌生 这是一种很常见的运算 我们在学习 信号与系统 时就一直在和卷积打交道 在后来的一些课程中也有卷积运算的身影 比如 自动控制原理现代部分 中的卷积定理等 在学习 信号与系统 时我们知道了卷积的定义 对于两个函数 f x f x f x 和 g x g x g x 他们的卷积 f g n f g n f g n 的公式如下 连续形式 f nbsp g n f g n d mathrm f mathrm g n int infty

    2025年8月27日
    4
  • opc服务器不显示目录,opc客户端搜不到opc服务器

    opc服务器不显示目录,opc客户端搜不到opc服务器opc客户端搜不到opc服务器内容精选换一换ELB可以针对客户访问的业务为访问者提供个性化的管理策略,制定策略之前需要获取来访者的真实IP。TOA内核模块主要用来获取ELB转化过的访问者真实IP地址(仅支持IPv4),该插件安装在ELB后端服务器。本文档仅适用于四层(TCP协议)服务,当客户需要在操作系统中编译TOA内核模块时,可参考本文档进行配置。Linux内核版本为2.6.32块存储调优主要…

    2022年6月20日
    33
  • Pycharm全局搜索快捷键失效「建议收藏」

    Pycharm全局搜索快捷键失效「建议收藏」问题很久没用pycharm的全局收缩快捷键。今天一用,发现用不了。后面才发现是与win10自带的输入法的繁简体切换快捷键冲突了。解决

    2022年5月6日
    100
  • 如何嗅闻交换网络和ARP骗子-ARP解释的原则

    如何嗅闻交换网络和ARP骗子-ARP解释的原则

    2022年1月11日
    41
  • matlab中importdata函数导入数据 到工作空间[通俗易懂]

    用load函数导入mat文件大家都会。但是今天我拿到一个数据,文件后缀名居然是‘.data’。该怎么读呢?我只好用matlab界面Workspace区域的“importdata”按钮手工导入该文件。恩,还好,居然成功了。顺便提一下,这个“importdata”按钮功能很强大,连excel文件都能导入。但是如果在脚本里如何导入这种非mat文件呢?这时候就轮到“import

    2022年4月17日
    223
  • openGL ES美颜滤镜之美白,磨皮,红润[通俗易懂]

    openGL ES美颜滤镜之美白,磨皮,红润[通俗易懂]下面是滤镜源码:importandroid.app.Activity;importandroid.content.Context;importandroid.graphics.Bitmap;importandroid.opengl.GLES20;importandroid.opengl.GLSurfaceView;importandroid.opengl.Matrix;importandroid.view.WindowManager;importcom.ws.gl.o

    2022年7月22日
    10

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号