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

大神说,这道题用母函数,但惭愧的说,自己还不了解母函数这东东,只能用数学的知识去做。这道题也告诉我们用1 ,2,5制作硬币,能够用尽可能少的硬币种数去表示其它的数

 

#include<iostream>
using namespace std;
int main(){
int a,b,c;
while(cin>>a>>b>>c)
{
if(a==0 && b==0 && c==0)
break;
else{
if(a==0)
cout<<1<<endl;
else{
if(a+2*b<4)
cout<<a+2*b+1<<endl;
else
cout<<a+2*b+1+5*c<<endl;
}
}
}
return 0;
}
//一定要注意{},不要偷懒

HD1085 Holding Bin-Laden Captive!的更多相关文章

  1. 缓冲区溢出利用——捕获eip的傻瓜式指南

    [译文] 摘要:为一个简单的有漏洞程序写一个简单的缓冲区溢出EXP,聚焦于遇到的问题和关键性的教训,提供详细而彻底的描述 内容表:1. I pity the fool, who can't smash ...

  2. 用主题模型可视化分析911新闻(Python版)

    本文由 伯乐在线 - 东狗 翻译,toolate 校稿.未经许可,禁止转载!英文出处:blog.dominodatalab.com.欢迎加入翻译小组. 本文介绍一个将911袭击及后续影响相关新闻文章的 ...

  3. How do I learn mathematics for machine learning?

    https://www.quora.com/How-do-I-learn-mathematics-for-machine-learning   How do I learn mathematics f ...

  4. Labeled Faces in the Wild 人脸识别数据集 部分测试数据

    development test set Note: images displayed are original (non-aligned/funneled) images. match pairs ...

  5. HDOJ 1085 Holding Bin-Laden Captive! (母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  6. HDU 1085 Holding Bin-Laden Captive! (母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  7. Holding Bin-Laden Captive!(母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  8. Holding Bin-Laden Captive!(杭电1085)(母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  9. Holding Bin-Laden Captive!(1.多重背包 2.母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...

随机推荐

  1. 图解phpstorm常用快捷键

    CTRL+N 查找类 CTRL+SHIFT+N 全局搜索文件 ,优先文件名匹配的文件 CIRL+B 找变量的来源,跳到变量申明处 (CTRL+ 鼠标单击 也可以) CTRL+G 定位行,跳转行 CTR ...

  2. Spring MVC的UrlBasedViewResolver和InternalResourceViewResolver

    Spring MVC使用ViewResolver来根据controller中返回的view名关联到具体的View对象.使用View对象来渲染返回值以生成最终的视图,如html,json或pdf等. S ...

  3. 51nod1120 机器人走方格 V3

    跟括号序列是一样的,将向右走看成是左括号向左走看成是右括号就可以了.那么就是卡特兰数了.然后由于n和m太大所以用了lucas定理 //跟括号序列是一样的,将向右走看成是左括号向左走看成是右括号就可以了 ...

  4. python练习程序(c100经典例10)

    题目: 打印楼梯,同时在楼梯上方打印两个笑脸. print '..' for i in range(1,9): print '**' for j in range(1,i+1): print ' ',

  5. 这篇博客的内容基本没见过,mark 一下以后可以学习

    初识机器学习算法有哪些? 机器学习无疑是现在数据分析领域的一个重要内容,凡事从事IT工作领域的人都在平时的工作中或多或少的会用到机器学习的算法. 机器学习有很多算法,不过大的方面可分为两类:一个是学习 ...

  6. getHibernateTemplate() 一直报NullPointerException 错误

    原来是调用方法有误正确调用方法: ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContex ...

  7. Brush、Color、String相互转换

    using System.Windows.Media; 1.String转换成Color Color color = (Color)ColorConverter.ConvertFromString(s ...

  8. JQUERY EASYUI 验证框(VALIDATEBOX)用法

    Query EasyUI 验证框(ValidateBox)在表单的验证方面给我们提供了很方便的方法,下面来介绍一下验证框(ValidateBox)的详细用法(查看演示):HTML 代码 <inp ...

  9. MVC和WebApi 使用get和post 传递参数。

    我们总结一下用js请求服务器的传参方法. Get方式 Get主要是用来查询,一般分为无参,一个参数,多个参数,实体对象参数. 1.无参 //Get没有参数 var get_f1 = function( ...

  10. Bootstrap学习笔记上(带源码)

    阅读目录 排版 表单 网格系统 菜单.按钮 做好笔记方便日后查阅o(╯□╰)o bootstrap简介: ☑  简单灵活可用于架构流行的用户界面和交互接口的html.css.javascript工具集 ...