10465 - Homer Simpson 贪心
| Homer Simpson | |
| Time Limit: 3 seconds Memory Limit: 32 MB | |
|  | Homer Simpson, a very smart guy, likes eating Krusty-burgers. It takes Homer m minutes to eat a Krusty- burger. However, there�s a new type of burger in Apu�s Kwik-e-Mart. Homer likes those too. It takes him n minutes to eat one of these burgers. Given t minutes, you have to find out the maximum number of burgers Homer can eat without wasting any time. If he must waste time, he can have beer. | 
Input
Input consists of several test cases. Each test case consists of three integers m, n, t (0 < m,n,t < 10000). Input is terminated by EOF.
Output
For each test case, print in a single line the maximum number of burgers Homer can eat without having beer. If homer must have beer, then also print the time he gets for drinking, separated by a single space. It is preferable that Homer drinks as little beer as possible.
Sample Input
3 5 54
3 5 55
Sample Output
18
17
题意:尽量用完时间t,求出最多吃多少个汉堡;如果实在用不完,再输出和啤酒的时间。
#include<stdio.h>
#include<string.h>
int main()
{
int m,n,t,max,i;
while(~scanf("%d%d%d",&m,&n,&t))
{
if(m>n) /*保证m>n*/
{int temp=m;m=n;n=temp;}
max=t/m; /*最多的数量*/
int beer_time=t-max*m; /*喝啤酒的时间*/
if(beer_time==0)
{
printf("%d\n",max);
continue;
}
for(i=1;i<=t/n;i++)
{
int temp_max=(t-n*i)/m+i;
int temp_beer_time=t-((temp_max-i)*m+i*n);
if(temp_beer_time>=0&&temp_beer_time<beer_time)
{
max=temp_max;
beer_time=temp_beer_time;
}
if(temp_beer_time==0)
break;
}
printf("%d",max);
if(beer_time!=0)
printf(" %d",beer_time);
printf("\n");
}
return 0;
}
10465 - Homer Simpson 贪心的更多相关文章
- UVa 10465 Homer Simpson (枚举)
		10465 - Homer Simpson Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ... 
- UVA 10465 Homer Simpson(全然背包: 二维目标条件)
		UVA 10465 Homer Simpson(全然背包: 二维目标条件) http://uva.onlinejudge.org/index.php? option=com_onlinejudge&a ... 
- UVA 10465 Homer Simpson(dp + 完全背包)
		Problem C: Homer Simpson Time Limit: 3 seconds Memory Limit: 32 MB Homer Simpson, a very smart guy, ... 
- UVa 10465 Homer Simpson(DP 全然背包)
		 题意 霍默辛普森吃汉堡 有两种汉堡 一中吃一个须要m分钟 还有一种吃一个须要n分钟 他共同拥有t分钟时间 要我们输出他在尽量用掉全部时间的前提下最多能吃多少个汉堡 假设时间无法用 ... 
- UVA题目分类
		题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ... 
- 算法入门经典大赛 Dynamic Programming
		111 - History Grading LCS 103 - Stacking Boxes 最多能叠多少个box DAG最长路 10405 - Longest Common Subsequence ... 
- 利用奇异值分解(SVD)简化数据
		特征值与特征向量 下面这部分内容摘自:强大的矩阵奇异值分解(SVD)及其应用 特征值分解和奇异值分解在机器学习领域都是属于满地可见的方法.两者有着很紧密的关系,在接下来会谈到,特征值分解和奇异值分解的 ... 
- [转载]javascript创建对象的几种方式
		原文链接:http://qingfeng825.iteye.com/blog/1935648 1. 工厂方法:能创建并返回特定类型对象的工厂函数(factory function). function ... 
- Code Complete阅读笔记(三)
		2015-05-26 628 Code-Tuning Techniques ——Even though a particular technique generally represen ... 
随机推荐
- JDK版本更换后编译android系统出错
			一:javac: 目标发行版 1.5 与默认的源发行版 1.7 冲突 1.设置jdk环境变量 编译android源码只支持jdk 1.6,所以如果需要编译源码必须下载jdk 1.6,不能下载最新的jd ... 
- Eclipse使用技巧及个性化设计
			以下除特殊说明均在 Windows->Preferences里面操作 如何把Eclipse关闭提示调出来? General->Startup and Shutdown,在 Confirm ... 
- Dom4j的使用(全而好的文章)
			版权声明: 本文由冰云完成,首发于CSDN,未经许可,不得使用于任何商业用途. 文中代码部分引用自DOM4J文档. 欢迎转载,但请保持文章及版权声明完整. 如需联络请发邮件:icecloud( ... 
- WordPress OptimizePress插件任意文件上传漏洞
			漏洞版本: WordPress OptimizePress Plugin 1.x 漏洞描述: WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设 ... 
- vijos p1193 扫雷
			描述 相信大家都玩过扫雷的游戏.那是在一个n*n的矩阵里面有一些雷,要你根据一些信息找出雷来.万圣节到了,“余”任过流行起了一种简单的扫雷游戏,这个游戏规则和扫雷一样,如果某个格子没有雷,那么它里 ... 
- jQuery append xmlNode 修改 xml 内容
			jQuery append xmlNode 修改 xml 内容 http://blog.darkthread.net/blogs/darkthreadtw/archive/2009/04/29/jqu ... 
- lightoj 1002
			最短路的变形,使用spfa做. #include<set> #include<map> #include<list> #include<stack> # ... 
- Vim 的粘贴复制功能
			Vim作为最好用的文本编辑器之一,使用vim来编文档,写代码实在是很惬意的事情.每当学会了vim的一个新功能,就会很大地提高工作效率.有人使用vim几十年,还没有完全掌握vim的功能,这也说明了vim ... 
- Linux内核结构分析与移植
			Linux内核主要的5个部分是:进程调度,内存管理,虚拟文件系统,网络接口,进程通信. 这5个部分之间的关系如下: (1)进程调度部分负责控制进程对CPU的访问. (2)内存管理允许多个进程安全地共享 ... 
- Storm系列(十六)架构分析之Executor-Bolt
			准备消息循环的数据 函数原型: 1 let[executor-sampler (mk-stats-sampler (:storm-conf executor-data))] 主要功能: 定义tupl ... 
