Holding Bin-Laden Captive!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13867    Accepted Submission(s): 6233

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!

 
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
 
Author
lcy
 #include <stdio.h>
#include <string.h>
int c1[],c2[];
int main()
{
int num_1,num_2,num_5;
while(scanf("%d%d%d",&num_1,&num_2,&num_5),num_1||num_2||num_5)
{
int i,j,k,n;
n = num_1+*num_2+*num_5;
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2));
for(i=;i<=num_1;i++)
c1[i]=;
for(j=;j<=(num_1+*num_2);j++)
for(k=;k+j<=n;k+=)
c2[k+j]+=c1[j];
for(j=;j<=(num_1+*num_2);j++)
c1[j]=c2[j];
memset(c2,,sizeof(c2));
for(j=;j<=n;j++)
for(k=;k+j<=n;k+=)
{
c2[k+j]+=c1[j];
}
for(j=;j<=n;j++)
c1[j]=c2[j];
for(i=;i<=n;i++)
if(!c1[i])
{
printf("%d\n",i);
break;
}
if(i>n)
printf("%d\n",n+);
}
return ;
}

最新文章

  1. winform对话框控件、打印控件
  2. struts2基础篇(1)
  3. 浏览器浏览记忆(history)几则技巧记录
  4. golang csv问题
  5. The first day!!!
  6. ios9+xcode7 适配笔记
  7. django中的事务管理
  8. Andoird 监听开机广播和关机广播
  9. avg 的使用
  10. mybatis百科-结果集映射类ResultMap
  11. 字符集和编码——Unicode(UTF&amp;UCS)深度历险
  12. Oracle 故障整理
  13. bzoj千题计划181:bzoj1878: [SDOI2009]HH的项链
  14. python 文件 IO 操作
  15. LinkedHashMap源码剖析
  16. 十分钟理解Actor模式
  17. fsync性能问题
  18. webpack开发模式和生产模式设置及不同环境脚本执行
  19. Centos7的iso everything与DVD以及Live的区别
  20. (一)ASP.NET中JavaScript的中英文(多语言)实现方案

热门文章

  1. jsp中提示修改成功
  2. AJPFX关于网络编程的理解
  3. hihocoder offer收割编程练习赛11 A hiho字符串
  4. 《基于Node.js实现简易聊天室系列之引言》
  5. IntelliJ IDEA安装与破解
  6. Android习惯——给全部Activity添加集合管理
  7. linux命令规范
  8. taskctl的后台字符界面登录不了解决办法
  9. 【Gambit】Gambit使用教程
  10. leetcode_655. Print Binary Tree