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


相关推荐

  • 未明确定义列什么原因_将多表数据汇总到一个表

    未明确定义列什么原因_将多表数据汇总到一个表运行环境:Oracle10gsqlplus环境下。 在查询语句中,经常会出现一个错误: SQL基础:ORA-00918:未明确定义列的错误。 当前遇到有两种情况。原因为:当查询语句中,查询的表(数据集)中有相同的字段名,查询字段无法确认是改查那个字段 时,就会报未明确定义列的错误。 第一种情况: 1.单表时: 比如fconsign表中存在三个字段:fcsg_c

    2022年10月5日
  • WinExec、ShellExecute用法详解「建议收藏」

    WinExec、ShellExecute用法详解「建议收藏」1、WinExec():  WinExec主要运行EXE文件,不能运行其他类型的文件,不用引用特别单元。原型是:UINTWinExec(exePath,ShowCmd)  参数说明:  –xePath:命令行参数。注意,要用pChar转化一下。  –ShowCmd:外部程序的运行方式。其取值如下:  —-SW_HIDE隐藏  —-SW_MAXI…

    2022年7月11日
  • AutoEventWireup属性的确切含义

    AutoEventWireup属性的确切含义使用Asp.NET时,新建的aspx页面第一行page指令中包含了一个AutoEventWireup属性。网上的很多教程认为这一属性,甚至这一行代码都是没用的。其实,这是不了解Asp.NET事件处理模型的表现。简单来说,这一属性决定了当前页是否自动关联某些特殊事件。    首先,从浏览器页面触发的事件不能立刻在本地得到处理,而是POST至服务器上,因此,Asp.NET建立了委托(代理)机制

    2022年5月28日
  • 求生之路2机枪mod_求生之路2好看的枪械mod名字

    求生之路2机枪mod_求生之路2好看的枪械mod名字动态子弹(弹匣)数量修改工具:GCFScape、notepad++、vpk.exe自己在搜索引擎输入文件名找资源教程:教程均假设修改smg的静态子弹和动态子弹,其他枪械修改一样,只不过修改对象不同。1.先找出武器原始的数据文件(1).打开GCFScape,左上角File-open。找到“\Steam\SteamApps\common\Left4Dead2\left4dead…

    2022年10月29日
  • Stairway to SQLCLR Level 5: Development (Using .NET within SQL Server)

    Stairway to SQLCLR Level 5: Development (Using .NET within SQL Server)原文链接:http://www.sqlservercentral.com/articles/Stairway+Series/119429/BySolomonRutzky,2015/03/11TheSeriesThisarticleispartoftheStairwaySeries:StairwaytoSQLCLRThepossibil

    2022年7月20日
  • bat批量修改文件名_bat批量修改文件夹名称不成功

    bat批量修改文件名_bat批量修改文件夹名称不成功在测试的时候,经常会遇到修改host的情况,每次都打开host手动添加,很繁琐地,怎么写个批处理文件,双击下就把host修改了呢,请看下面代码:@echooffcolor0F@attrib-r”%windir%\system32\drivers\

    2022年10月9日

发表回复

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

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