HDU - 1085 母函数
年轻人的第一道母函数入门题
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000+2000+5000+1;
#define rep(i,j,k) for(int i = j; i <= k; i++)
#define rep2(i,j,k) for(int i = j; i <= k; i+=2)
#define rep3(i,j,k) for(int i = j; i <= k; i+=5)
int coin[3][maxn];
int main(){
ios::sync_with_stdio(0);
int a,b,c;
while(cin>>a>>b>>c){
if(!a&&!b&&!c) break;
memset(coin,0,sizeof coin);
rep(i,0,a) coin[0][i]=1;
rep(i,0,a) rep2(j,0,2*b) coin[1][i+j]+=coin[0][i];
rep(i,0,a+2*b) rep3(j,0,5*c) coin[2][i+j]+=coin[1][i];
bool flag=0;
rep(i,0,a+2*b+5*c) if(coin[2][i]==0){
cout<<i<<endl;
flag=1;
break;
}
if(flag==0) cout<<a+2*b+5*c+1<<endl;
}
return 0;
}
HDU - 1085 母函数的更多相关文章
- hdu 1028 母函数 一个数有几种相加方式
///hdu 1028 母函数 一个数有几种相加方式 #include<stdio.h> #include<string.h> #include<iostream> ...
- HDU 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)
题意: 有面值分别为1.2.5的硬币,分别有num_1.num_2.num_5个,问不能组成的最小面值是多少?(0<=每种硬币个数<=1000,组成的面值>0) 思路: 母函数解决. ...
- 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! (母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- hdu 1085 有num1个 1 ,num2个 2 ,num3个 5 (母函数)
有num1个 1 ,num2个 2 ,num3个 5问它们不能组成的最小正整数是谁 样例的母函数 (1+X)(1+X2)(1+X5+X10+X15)展开后 X4的系数为0 Sample Input1 ...
- 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! (母函数)
//给你面值为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!
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- hdu 1085(普通母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
随机推荐
- jQuery--修改表单数据并提交
目的: 点击'编辑',弹出对话框,修改数据. 主要知识点: prevAll(),获取同级别本元素前面的所有元素. 代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
- anacondas 下 安装xgboost & keras
mac : 安装anaconda, cd到anaconda 目录下 pip install xgboost 测试: 在当前的¥ python , 进入python 环境 import xgboost ...
- Luogu 3665 [USACO17OPEN]Switch Grass 切换牧草
BZOJ 4777 被权限了. 这道题的做法看上去不难,但是感觉自己yy不出来. 首先是两个结论: 1.答案一定是连接着两个异色点的一条边. 2.答案一定在最小生成树上. 感觉看到了之后都比较显然,自 ...
- 数据库MySQL 之 库操作
数据库MySQL 之 库操作 浏览目录 系统数据库简介 数据库操作 命名规范 用户权限 修改密码 忘记密码 中文乱码问题 一.系统数据库简介 information_schema :虚拟库,不占用磁盘 ...
- c++(重载等号=操作为深拷贝)
// ConsoleApplication19.cpp : 定义控制台应用程序的入口点. // #pragma warning(disable:4996) #include "stdafx. ...
- 利用 Aspose.Words 组件,在不依赖与 Office 组件的情况下把 Word 文件转换成 HTML 代码。
首先利用 Nuget 获取 Aspose.Words.dll public ActionResult AsposeWordsDemo() { string srcFileName = Server.M ...
- How to safely shut down a loading UIWebView in viewWillDisappear?
up vote24down votefavorite 24 I have a view containing a UIWebView which is loading a google map (so ...
- MYSQL常用日期操作
mysql查询今天.昨天.7天.近30天.本月.上一月 数据 今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT ...
- C++小学生四则运算_余伟淇_郑鉴
https://github.com/kielingpao/sizeyunsuan 项目相关要求 1题目:实现一个自动生成小学四则运算题目的命令行程序 2说明 自然数:0, 1, 2, ….• 真分数 ...
- MVC Action控制方式
1.Controller 的OnActionExecuting中控制 protected override void OnActionExecuting(ActionExecutingContext ...