hdu1085
来源:互联网 发布:什么题库软件好 编辑:程序博客网 时间:2024/05/31 19:57
Holding Bin-Laden Captive!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14134 Accepted Submission(s): 6327
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! ”
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!
“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!
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 30 0 0
Sample Output
4
#include<cstring>#include<cstdio>#include<iostream>using namespace std;int c1[10000],c2[10000];int num[4];int main(){while(scanf("%d %d %d", &num[1], &num[2], &num[3])&&(num[1]||num[2]||num[3])){int _max = num[1]+num[2]*2+num[3]*5;memset(c1, 0, sizeof(int)*_max);memset(c2, 0, sizeof(int)*_max);for(int i = 0; i <= num[1]; i++){c1[i] = 1;}for(int i = 0; i <= num[1]; i++){for(int j = 0; j <=num[2]*2; j+=2){c2[i+j] += c1[i];}}for(int i = 0; i <=num[2]*2+num[1]; i++){c1[i] = c2[i];c2[i] = 0;}for(int i = 0; i <= num[2]*2+num[1]; i++){for(int j = 0; j <= num[3]*5; j+=5){c2[i+j] += c1[i];}}int i;for(i = 0; i <=_max; i++){if(c2[i]==0){cout<<i<<endl;break;}}if(i == _max+1){cout<<i<<endl;}}return 0;}
0 0
- hdu1085
- hdu1085
- hdu1085
- hdu1085!【数学】
- hdu1085 母函数
- hdu1085(母函数)
- [贪心]HDU1085 Moving Tables
- HDU1085(母函数)
- HDU1085(母函数)
- hdu1085【母函数入门】
- HDU1085(母函数模板)
- hdu1085母函数模板
- HDU1085 多重背包
- hdu1085-Holding Bin-Laden Captive!
- hdu1085 Holding Bin-Laden Captive!
- hdu1085 Holding Bin-Laden Captive!
- HDU1085 Holding Bin-Laden Captive!
- HDU1085 Holding Bin-Laden Captive!
- Kernel 启动参数解析
- java中static关键字
- Memcache 初体验
- 昨晚看泰坦尼克号首映的唯一亮点,就是Rose脱了一半快完时镜头突然被切换,全场异口同声的那句:草!
- 分布式服务框架 Zookeeper -- 管理分布式环境中的数据
- hdu1085
- 天购:让“免费”的理念成功起航
- Java 中 Vector、ArrayList、List 使用深入剖析
- Linux __setup解析
- 6今晚5j6w
- mesa3d编译
- js传参数却显示科学计数法
- MAVEN项目标准目录结构
- 快速检索盘的实现