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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • linux脚本使用scp自动传输,shell脚本实现scp文件传输

    linux脚本使用scp自动传输,shell脚本实现scp文件传输scp是一个基于ssh的Linux环境下传输文件的好工具,但是使用shell脚本调用scp时会面临一个问题,即scp强制要求通过交互方式输入密码,而不像mysql等拥有-u-p选项。下面有两种方法帮助shell脚本跨过输入密码这个障碍。1.建立机器间完全信任关系假设需要从机器A传输文件至机器B1)在机器A上运行#ssh-keygen-trsa上述命令会在~/.ssh/目录生成私钥证书id_…

    2022年8月22日
    9
  • 利用python画图

    利用python画图因为最近论文收尾需要画图,于是学了一些画图的东西在这里分享一下一、环境配置 linuxubuntu下需安装下面三个包:Numpy,Scipy,Matplotlib分别输入下面的代码进行安装:二、开始画一些简单的图(1)直线图#coding:utf-8importnumpyasnpimportmatplotlib.pyplotaspltx=…

    2022年5月6日
    57
  • 英语不好也能写好论文

    英语不好也能写好论文

    2021年9月7日
    40
  • 驾校学员管理系统_驾校管理系统

    驾校学员管理系统_驾校管理系统mysql-uroot-p-u表示选择登陆的用户名,-p表示登陆的用户密码,上面命令输入之后会提示输入密码,此时输入密码就可以登录到mysql创建数据库:createdatabasedrivingschool;选择数据库:usedrivingschool;转载于:https://www.cnblogs.com/zgytbn/p/8296799.html…

    2022年9月20日
    0
  • 彻底解决Intellij IDEA中文乱码问题(亲测成功)「建议收藏」

    关于JAVA IDE开发工具,Eclipse系列和Intelli IDEA是大部分公司的主要选择,从开发者的选择角度,Intellij IDEA似乎比Eclipse系列更受欢迎一些。当我们使用Intellij IDEA开发时,我们发现出现中文乱码问题,造成中…

    2022年3月13日
    2.9K
  • 福利吧简约朴素网站地址发布页源码

    福利吧简约朴素网站地址发布页源码介绍:大方简约的地址发布页面HTML源码,可用于发布网站最新地址,留住用户必备方便找到回家的路,就单单一个html页面,需要的朋友下载吧!网盘下载地址:https://zijiewangpan.com/Lgv39T6zCtT图片:…

    2022年5月26日
    63

发表回复

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

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