HDU 1085 母函数
来源:互联网 发布:淘宝怎么实名认证激活 编辑:程序博客网 时间:2024/05/16 16:10
Holding Bin-Laden Captive!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17767 Accepted Submission(s): 7955
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<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int num[105],price[105],c1[100000],c2[100000],c3[100000];
int main()
{
int a=0,b=0,c=0;
while(scanf("%d%d%d",&a,&b,&c),a+b+c)
{
memset(c1,0,sizeof(c1));
memset(c2,0,sizeof(c2));
memset(c3,0,sizeof(c3));
for(int i=0;i<=a;i++)
c1[i]=1;
for(int i=0;i<=b*2;i+=2)
{
for(int j=0;j<=a;j++)
{
c2[i+j]=c2[i+j]+c1[j];
}
}
for(int i=0;i<=c*5;i+=5)
{
for(int j=0;j<=a+2*b;j++)
{
c3[i+j]=c3[i+j]+c2[j];
}
}
for(int i=0;1;i++)
{
if(c3[i]==0)
{
printf("%d\n",i);
break;
}
}
}
return 0;
}
#include<iostream>
#include<cstring>
using namespace std;
int num[105],price[105],c1[100000],c2[100000],c3[100000];
int main()
{
int a=0,b=0,c=0;
while(scanf("%d%d%d",&a,&b,&c),a+b+c)
{
memset(c1,0,sizeof(c1));
memset(c2,0,sizeof(c2));
memset(c3,0,sizeof(c3));
for(int i=0;i<=a;i++)
c1[i]=1;
for(int i=0;i<=b*2;i+=2)
{
for(int j=0;j<=a;j++)
{
c2[i+j]=c2[i+j]+c1[j];
}
}
for(int i=0;i<=c*5;i+=5)
{
for(int j=0;j<=a+2*b;j++)
{
c3[i+j]=c3[i+j]+c2[j];
}
}
for(int i=0;1;i++)
{
if(c3[i]==0)
{
printf("%d\n",i);
break;
}
}
}
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 母函数(二)
- 使用PHP生成二维码的两种方法(带logo图像)
- 机器学习算法总览——思维导图
- 数据库(sqlite3)项目实际应用
- 最少找零问题与完全背包模型的一点思考
- Letter Combinations of a Phone Number
- HDU 1085 母函数
- oc学习笔记-protocol代理模式
- 使用netstat检测及监测网络连接
- BFS与DFS
- 004.简单的加减乘除
- Cache工作原理
- XDebug
- iOS 开发之 AutoLayout 自动布局
- Core Data初解