hdu 1085 母函数
来源:互联网 发布:sftp 命令行 指定端口 编辑:程序博客网 时间:2024/05/22 06:23
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
题解:
给定1,2,5硬币个数,问最小组成的硬币总数是多少?
母函数模板
代码:
#include <bits/stdc++.h>using namespace std;int v[3]={1,2,5};int n[3],a[9000],b[9000],i,j,k,last,last2;int main(){while(cin>>n[0]>>n[1]>>n[2]&&(n[0]+n[1]+n[2])){ a[0]=1; last=0; for (int i=0;i<3;i++) { last2=last+n[i]*v[i]; memset(b,0,sizeof(int)*(last2+1)); for (j=0;j<=n[i]&&j*v[i]<=last2;j++) for (k=0;k<=last&&k+j*v[i]<=last2;k++) b[k+j*v[i]]+=a[k]; memcpy(a,b,sizeof(int)*(last2+1)); last=last2; } for(i=0;i<=last;i++) if(a[i]==0) break; cout<<i<<endl;} return 0;}
阅读全文
0 0
- hdu 1085 母函数
- HDU--1085 (母函数)
- hdu 1085 母函数
- HDU 1085 母函数
- HDU 1085 母函数
- hdu 1085 母函数
- hdu 1085 母函数
- HDU 1085 1028 母函数
- hdu 1085(普通型母函数)
- HDU 1085 (母函数)
- HDU 1085 母函数/思维
- HDU 1085 简单母函数
- HDU 1085 (母函数)
- hdu 1085 普通母函数
- 母函数的应用 :HDU 1028/ HDU 1328 / HDU 1085
- 母函数初级运用 hdu 1028 、hdu 1398、hdu 1085
- hdu 1085 母函数---有限个
- hdu 1085 母函数(二)
- Android开发 第11课 AbsoluteLayout
- Java学习路线图
- 网络安全技术之外网限制
- HDU 1064
- activiti学习笔记(三) 监听生命周期
- hdu 1085 母函数
- 数据库事务的四大特性以及事务的隔离级别
- Nginx配置详解
- Android开发 第12课 TableLayout
- 并查集
- python3 [爬虫入门实战]爬取熊猫直播用户信息
- linux初学者-ftp篇(一)
- 欢迎使用CSDN-markdown编辑器
- 区块链火爆,为何巨头还未入场