uva10465Homer Simposon(完全背包)
发布日期:2022-02-02 02:58:10 浏览次数:24 分类:技术文章

本文共 1462 字,大约阅读时间需要 4 分钟。

Problem C: 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 543 5 55

Sample Output

1817

Problem setter: Sadrul Habib Chowdhury

Solution author: Monirul Hasan (Tomal)

Time goes, you say? Ah no!

Alas, Time stays, we go.
-- Austin Dobson

#include 
#include
using namespace std;int dp[10001];int w[3];int sum[10001];int main(){ int m,n,t,i,j; while(cin>>m>>n>>t) { w[1]=m;w[2]=n; memset(dp,0,sizeof(dp)); memset(sum,0,sizeof(sum)); for(i=1;i<=2;i++) { for(j=0;j<=t;j++) { if(j>=w[i]) { if(dp[j]

转载地址:https://blog.csdn.net/u010368749/article/details/19828543 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:最长公共上升子序列(LIS)
下一篇:uva147Dollars(完全背包)

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月09日 15时46分26秒