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

非常明显的全然背包问题  求两次  一次对个数  一次对时间即可了   时间用不完的情况下就输出时间的

d1为个数的  d2为时间的  dt保存时间

#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 10005
using namespace std;
int w[2],t,d1[maxn],d2[maxn],dt[maxn];
int main()
{
while (scanf("%d%d%d",&w[0],&w[1],&t)!=EOF)
{
memset(d1,0x8f,sizeof(d1));
memset(dt,0,sizeof(dt));
memset(d2,0,sizeof(d2));
d1[0]=0;
for(int i=0; i<2; ++i)
for(int j=w[i]; j<=t; ++j)
{
d1[j]=max(d1[j],d1[j-w[i]]+1);
if((dt[j]<dt[j-w[i]]+w[i])||((dt[j]==dt[j-w[i]]+w[i])&&(d2[j]<d2[j-w[i]]+1)))
{
dt[j]=dt[j-w[i]]+w[i];
d2[j]=d2[j-w[i]]+1;
}
}
if(dt[t]==t)
printf("%d\n",d1[t]);
else
printf("%d %d\n",d2[t],t-dt[t]);
}
return 0;
}
Homer Simpson
 

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

UVa 10465 Homer Simpson(DP 全然背包)的更多相关文章

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

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

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

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

  3. UVa 10465 Homer Simpson (枚举)

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

  4. UVA.674 Coin Change (DP 完全背包)

    UVA.674 Coin Change (DP) 题意分析 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 每种硬币的数量是无限的.典型完全背包. 状态 ...

  5. 10465 - Homer Simpson 贪心

                                            Homer Simpson Time Limit: 3 seconds Memory Limit: 32 MB Home ...

  6. UVA 562 Dividing coins(dp + 01背包)

    Dividing coins It's commonly known that the Dutch have invented copper-wire. Two Dutch men were figh ...

  7. UVA 357 Let Me Count The Ways(全然背包)

    UVA 357 Let Me Count The Ways(全然背包) http://uva.onlinejudge.org/index.php?option=com_onlinejudge& ...

  8. UVA 10306 e-Coins(全然背包: 二维限制条件)

    UVA 10306 e-Coins(全然背包: 二维限制条件) option=com_onlinejudge&Itemid=8&page=show_problem&proble ...

  9. UVA.357 Let Me Count The Ways (DP 完全背包)

    UVA.357 Let Me Count The Ways (DP 完全背包) 题意分析 与UVA.UVA.674 Coin Change是一模一样的题.需要注意的是,此题的数据量较大,dp数组需要使 ...

随机推荐

  1. PCB MS CLR 聚合函数 joinString加排序实现

    准备着手,动态列SQL查询,要实现动态列SQL,会运用到聚合函数,而SQL本身聚合函数有限, 无满足此用户任意字段组合变化,再加上工艺流程重复相同工序,如;沉铜1,沉铜2对应工序代码都是相同的 而通常 ...

  2. mysql数据库的介绍及安装

    一.什么是数据库 1.什么是数据(Data) 描述事物的符号记录成为数据,描述事物的符号既可以是文字.图片.图像.声音.语言等,数据有多种表现形式,他们都可以经过数字化后存入计算机 在计算机中描述一个 ...

  3. windows phone媒体应用开发

    MediaElement 可以播放许多不同类型的音频和视频媒体. MediaElement 是一个可以在其表面显示视频的矩形区域,也可以播放音频.MediaElement 支持触控输入事件. 使用属性 ...

  4. swift-自定义TabBar工具栏

    class EBTAppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(ap ...

  5. Hive2.1.1集群搭建

    软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这五部机, 每部主机的用户名都为centos ...

  6. VHDL之concurrent之block

    1 Simple BLOCK The simple block represents only a way of partitioning the code. It allows concurrent ...

  7. SmartUpload实现文件上传

    (一)SmartUpload组件简介 SmartUpload组件 专门用于实现文件上传及下载的免费组件   (二)SmartUpload组件特点 使用简单:编写少量代码,完成上传下载功能 能够控制上传 ...

  8. POJ 1000

    #include <iostream> int main() { using std::cin; using std::cout; using std::endl; int a,b; ci ...

  9. 推荐几个好用的windows软件

    好久没上了,= = 之前用了一段MAC,感觉好用的地方就是 spotlight和触摸板,哈哈 然后在用回windows之后就找了一下,我之前有用Launchy这个软件,但是他是用来启动程序的,当然你也 ...

  10. 作业08之《MVC实现用户权限》

    1. 赋给用户一个userid,在用户角色表将用户和角色关联起来,在角色权限表中将角色和权限对应起来,权限表中存储的是左边菜单栏的名称. 2. 在判断权限时,通过用户的userid,获取其角色id,然 ...