UVA 10465 Homer Simpson
来源:互联网 发布:unity3d鼠标点击物体 编辑:程序博客网 时间:2024/05/21 09:49
在t分钟内吃两种耗时不同的汉堡,首先保证耗时最多,然后保证汉堡吃最多,最后剩下的时间喝酒
#include<iostream>#include<map>#include<string>#include<cstring>#include<cstdio>#include<cstdlib>#include<cmath>#include<queue>#include<vector>#include<algorithm>using namespace std;int main(){int a[2];int dp[2][10010];int i,j,t;while(cin>>a[0]>>a[1]>>t){memset(dp,0,sizeof(dp));for(i=0;i<2;i++)for(j=a[i];j<=t;j++)if(dp[0][j]<dp[0][j-a[i]]+a[i]){dp[0][j]=dp[0][j-a[i]]+a[i];dp[1][j]=dp[1][j-a[i]]+1;}else if(dp[0][j]==dp[0][j-a[i]]+a[i])dp[1][j]=max(dp[1][j],dp[1][j-a[i]]+1);cout<<dp[1][t];if(dp[0][t]!=t)cout<<" "<<t-dp[0][t];cout<<endl;}}
Return of the Aztecs
Problem C:Homer SimpsonTime 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 integersm, 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 543 5 55
Sample Output
1817
0 0
- uva 10465 Homer Simpson
- uva 10465 Homer Simpson
- UVA 10465 Homer Simpson
- UVa 10465 - Homer Simpson
- UVa 10465 - Homer Simpson
- uva 10465 Homer Simpson
- UVa 10465 - Homer Simpson
- Uva-10465-Homer Simpson
- UVa:10465 Homer Simpson
- UVA - 10465 Homer Simpson
- uva 10465 - Homer Simpson
- UVa 10465 - Homer Simpson
- uva 10465 Homer Simpson
- UVa 10465 - Homer Simpson
- UVA - 10465 Homer Simpson
- UVA 10465 Homer Simpson
- UVA 10465 Homer Simpson
- uva 10465 Homer Simpson
- 在CentOS 7上遇到的一些问题,以及自己的解决方法
- 操纵C 风格字符串标准库函数
- 安装cuda6.5
- struts2+spring+hibernate三大框架环境搭建小小总结
- 百度地图API3.1.1版之添加标注物+UI控制+定位
- UVA 10465 Homer Simpson
- Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tool
- [LeetCode] Remove Nth Node From End of List
- 给UIlabel设置不同字体 颜色 下划线
- 第十三周 项目四:数组的排序(1.4选择排序)
- 嗨图SDK,让你的APP”嗨“起来!
- php实现图片加水印
- dubbo的安装和使用
- JPA project Change Event Handler导致工具卡顿解决