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 贪心的更多相关文章

  1. UVa 10465 Homer Simpson (枚举)

    10465 - Homer Simpson Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...

  2. UVA 10465 Homer Simpson(全然背包: 二维目标条件)

    UVA 10465 Homer Simpson(全然背包: 二维目标条件) http://uva.onlinejudge.org/index.php? option=com_onlinejudge&a ...

  3. UVA 10465 Homer Simpson(dp + 完全背包)

    Problem C: Homer Simpson Time Limit: 3 seconds Memory Limit: 32 MB Homer Simpson, a very smart guy, ...

  4. UVa 10465 Homer Simpson(DP 全然背包)

     题意 霍默辛普森吃汉堡  有两种汉堡  一中吃一个须要m分钟  还有一种吃一个须要n分钟  他共同拥有t分钟时间    要我们输出他在尽量用掉全部时间的前提下最多能吃多少个汉堡  假设时间无法用 ...

  5. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  6. 算法入门经典大赛 Dynamic Programming

    111 - History Grading LCS 103 - Stacking Boxes 最多能叠多少个box DAG最长路 10405 - Longest Common Subsequence ...

  7. 利用奇异值分解(SVD)简化数据

    特征值与特征向量 下面这部分内容摘自:强大的矩阵奇异值分解(SVD)及其应用 特征值分解和奇异值分解在机器学习领域都是属于满地可见的方法.两者有着很紧密的关系,在接下来会谈到,特征值分解和奇异值分解的 ...

  8. [转载]javascript创建对象的几种方式

    原文链接:http://qingfeng825.iteye.com/blog/1935648 1. 工厂方法:能创建并返回特定类型对象的工厂函数(factory function). function ...

  9. Code Complete阅读笔记(三)

    2015-05-26   628   Code-Tuning Techniques    ——Even though a particular technique generally represen ...

随机推荐

  1. LinuxShell_variable+if+while

    [root@ossec-server mybash]# vim ./hello.sh #! /bin/sh # This is a example bash script echo "Hel ...

  2. Oracle系列之权限

    涉及到表的处理请参看原表结构与数据  Oracle建表插数据等等 赋予权限:前三个要在管理员权限用户下进行操作 方法1: grant dba to db_user;--赋予用户数据库管理权限 方法2: ...

  3. Maprduce重写参考

    Maprduce数据流走向图:   流程解释    Input files        功能描述:存储在HDFS中的文件数据        InputFormat            功能描述:1 ...

  4. 如何修改word的项目编号

    在操作word文档时,有时会遇到word文档中的项目编号不是自己需要的,并造成word项目编号的混乱,如何word中的两级项目编号不统一,为解决会word的项目编号混乱问题,小编将教大家如何修改wor ...

  5. combobox的下拉框高度怎样设计合理

    orry,代码如下$.extend($.fn.combobox.methods, {        autoHeight : function (jq) {//combobox扩展,自动调整高度    ...

  6. 安全delete,添加refenerce,release

    #ifndef SAFE_ADDREF#define SAFE_ADDREF(p)    if (p != NULL) { p->AddRef(); }#endif #ifndef SAFE_R ...

  7. [转]ASP.NET MVC 入门1、简介

    什么是MVC模式 MVC(Model-View-Controller,模型—视图—控制器模式)用于表示一种软件架构模式.它把软件系统分为三个基本部分:模型(Model),视图(View)和控制器(Co ...

  8. 【转】RDO、SAD、SATD、λ

    SAD(Sum of Absolute Difference)=SAE(Sum of Absolute Error)即绝对误差和 SATD(Sum of Absolute Transformed Di ...

  9. Sql->Linq-> Lambda 相互转换

    Linq 转 SQL 或 Linq 转 Lambda : 工具: LinqPad Sql 转 Linq to Entity: 工具: Linqer

  10. JDK1.5新特性(三)……Varargs

    援引 Varargs - This facility eliminates the need for manually boxing up argument lists into an array w ...