HDU 1085-Holding Bin-Laden Captive!(生成功能)
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
“Oh, God! How terrible! ”

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!
1 1 3
0 0 0
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;
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
HDU 1085-Holding Bin-Laden Captive!(生成功能)的更多相关文章
- HDU 1085 Holding Bin-Laden Captive! (母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDU 1085 Holding Bin-Laden Captive!(母函数,或者找规律)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDU 1085 Holding Bin-Laden Captive!(DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1085 解题报告:有1,2,5三种面值的硬币,这三种硬币的数量分别是num_1,num_2,num_5, ...
- HDOJ/HDU 1085 Holding Bin-Laden Captive!(非母函数求解)
Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for ...
- hdu 1085 Holding Bin-Laden Captive!
Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for ...
- HDU 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)
题意: 有面值分别为1.2.5的硬币,分别有num_1.num_2.num_5个,问不能组成的最小面值是多少?(0<=每种硬币个数<=1000,组成的面值>0) 思路: 母函数解决. ...
- HDU 1085 Holding Bin-Laden Captive --生成函数第一题
生成函数题. 题意:有币值1,2,5的硬币若干,问你最小的不能组成的币值为多少. 解法:写出生成函数: 然后求每项的系数即可. 因为三种硬币最多1000枚,1*1000+2*1000+5*1000=8 ...
- hdu 1085 Holding Bin-Laden Captive! (母函数)
//给你面值为1,2,5的三种硬币固定的数目,求不能凑出的最小钱数 //G(x)=(1+x+...+x^num1)(1+x^2+...+x^2num2)(1+x^5+,,,+x^5num3), //展 ...
- 代码生成工具Database2Sharp中增加视图的代码生成以及主从表界面生成功能
在代码生成工具的各种功能规划中,我们一向以客户的需求作为驱动,因此也会根据需要增加一些特殊的功能或者处理.在实际的开发中,虽然我们一般以具体的表进行具体业务开发,但是有些客户提出有时候视图开发也是很常 ...
- Taurus.MVC 2.3 开源发布:增强属性Require验证功能,自带WebAPI文档生成功能
背景: 上周,把 Taurus.MVC 在 Linux (CentOS7) 上部署任务完成后. 也不知怎么的,忽然就想给框架集成一下WebAPI文档功能,所以就动手了. 以为一天能搞完,结果,好几天过 ...
随机推荐
- 【Ruby】Ruby的model学习——Active Record Associations
在阅读的过程中有不论什么问题,欢迎一起交流 邮箱:1494713801@qq.com QQ:1494713801 一.怎样定义关联 两个model之间经常会存在关联关系,为了解决这些关联引起的复 ...
- Codeforces 61E Enemy is weak 乞讨i<j<k && a[i]>a[j]>a[k] 对数的 树阵
主题链接:点击打开链接 意大利正在寻求称号 i<j<k && a[i]>a[j]>a[k] 的对数 假设仅仅有2元组那就是求逆序数的做法 三元组的话就用一个树状 ...
- ASP.NET Web Service应用发布到IIs怎么做
首先把你写的webservice Publish 到 一个文件夹 D:\MyWebService 下,在IIS下的website里面new一个虚拟目录,别名(Alias)随便输一个(这个别名是用于别的 ...
- Win7下不能查看xp系统共享的文件,解决方法
近期在做一个程序,xp执行良好.win7总是打不开文件,输入地址訪问\\192.168.0.254,发现须要输入usernamepassword 局域网内的XP电脑能够訪问WIN7的共享文件.而WIN ...
- php中页面跳转部分方法论述
假设当前页面:http://localhost:80/index.php 1.include echo “include t1.php”; 跳转后,url地址栏http://localhost:80/ ...
- uva 11722 - Joining with Friend(概率)
题目连接:uva 11722 - Joining with Friend 题目大意:你和朋友乘火车,而且都会路过A市.给定两人可能到达A市的时段,火车会停w.问说两人能够见面的概率. 解题思路:y = ...
- embedded dylibs/frameworks are only supported on iOS 8.0 and later 错误解决
ld: warning: embedded dylibs/frameworks only run on iOS 8 or later ld: embedded dylibs/frameworks ar ...
- (Android+IOS)我们正在做一个新闻App,做几乎一样的,倾听您的建议 (画画)
(Android+IOS)我们正在做一个新闻App,做几乎一样的,倾听您的建议! 新闻采访是做,前端展示APP界面感觉还不是非常好,还须要改进改进,希望公布(Android和IOS版本号)前听听大家的 ...
- Storm具体解释一、Storm 概述
一.Storm概述 Storm是一个分布式的.可靠的.零失误的流式数据处理系统. 它的工作就是委派各种组件分别独立的处理一些简单任务.在Storm集群中处理输入流的是Spout组件,而Spo ...
- oracle 11g impdp时 报ORA-12899(转)
源库ZHS16BGK,汉字在数据库存放的时候占用两个字节 目标库UTF8,汉字在数据库里存放的时候占用三个字节 由于字符集不同,导致现在数据库impdp的时候有些表的字段长度不够,出现ORA-1289 ...