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): 17653 Accepted Submission(s): 7902
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! ”
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!
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.
0 0 0
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 1002
int n1,n2,n5; int ziji(int n1,int n2,int n5)
{
int ans;
if(n1==)ans=;
else if(n2==&&n1<)ans=;
else if(n1==&&n2==)ans=;
else if(n1==&&n2==&&n5>)ans=;
else if(n1==&&n2==&&n5>)ans=;//第一次少了这种情况
else
{
ans=n1+n2*+n5*+;
}
return ans;
} int main()
{
while(~scanf("%d%d%d",&n1,&n2,&n5)&&n1+n2+n5>)
{
cout<<ziji(n1,n2,n5)<<endl;
}
return ;
}
母函数方法:
HDU 1085 Holding Bin-Laden Captive!(母函数,或者找规律)的更多相关文章
- 【hdu 6172】Array Challenge(数列、找规律)
多校10 1002 HDU 6172 Array Challenge 题意 There's an array that is generated by following rule. \(h_0=2, ...
- HDU 2147 kiki's game(博弈图上找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题目大意:给你一个n*m的棋盘,初始位置为(1,m),两人轮流操作,每次只能向下,左,左下这三个 ...
- HDU 1085 Holding Bin-Laden Captive! (母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- 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! 活捉本拉登(普通型母函数)
题意: 有面值分别为1.2.5的硬币,分别有num_1.num_2.num_5个,问不能组成的最小面值是多少?(0<=每种硬币个数<=1000,组成的面值>0) 思路: 母函数解决. ...
- 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), //展 ...
- 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, ...
- 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的硬币若干,问你最小的不能组成的币值为多少. 解法:写出生成函数: 然后求每项的系数即可. 因为三种硬币最多1000枚,1*1000+2*1000+5*1000=8 ...
随机推荐
- ubuntu下svn在挂在的NTFS分区上无法报错,提示没有权限
终极解决方案: 赋予svn文件root权限 1. 查找svn文件: $ whereis svn svn: /usr/bin/svn /usr/bin/X11/svn /usr/share/.gz $ ...
- Matplotlib基本图形之直方图
Matplotlib基本图形之直方图 直方图特点 由一系列高度不等的纵向条形组成,表示数据分布情况例如年级同学身高分布注意与条形图的区别 示例代码: import osimport numpy as ...
- OSPF 提升四 Network Types & FRAM-RELAY
Network Types 1.loopback 2.point-to-point 3.broadcast 4.NBMA 5.POINT-TO-Multipoint 6.point-To-Multip ...
- [uiautomator篇] bluetooth---接口来做
package com.softwinner.performance.frameratetest; import android.Manifest; import android.bluetooth. ...
- .NET重构(三):在注册和充值中,触发器的使用
导读:机房做到注册和充值了,有两个关键点:在注册的时候,同时给该用户写入充值记录:在充值的时候,给该用户更改余额信息.第一次做的时候,是一条一条的写,那时候师傅就说了触发器和存储过程的使用,现在终于用 ...
- vue 使用Echarts 环形图 自定义legend formatter 富文本标签
main.js 引入echarts // 引入echarts import Echarts from 'echarts' Vue.prototype.$echarts = Echarts < ...
- 【Luogu】P3195玩具装箱(斜率优化DP)
这题还是比较炫的 题目链接 我们设f[i]是已经装了前i个玩具,且第i个玩具是某箱子里装的最后一个东西(废话) 那我们很轻松可以想到一个转移方程 ;i<=n;++i) ;j<i;++j) ...
- 最小的图灵完备语言——BrainFuck
最小的图灵完备语言--BrainFuck 图灵完备性(Turing completness) 在可计算性理论(computability theory)中,图灵等价指的是:对于两个计算机A和B,如果A ...
- java.lang.Class解析
java.lang.Class 1.java.lang.Class的概念 当一个类或接口被装入的JVM时便会产生一个与之关联的java.lang.Class对象,java.lang.class类就是用 ...
- Caffe的Solver参数设置
Caffe的solver参数设置 http://caffe.berkeleyvision.org/tutorial/solver.html solver是通过协调前向-反向传播的参数更新来控制参数优化 ...