设为首页 加入收藏

TOP

UVA 10465 Homer Simpson(贪心,在给定时间内吃的最多的汉堡数目)
2015-07-20 17:56:54 来源: 作者: 【 】 浏览:1
Tags:UVA 10465 Homer Simpson 贪心 时间 汉堡 数目

Homer Simpson Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu

Description

Download as PDF

Return of the Aztecs

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.<??http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPGgzPk91dHB1dDwvaDM+CjxwPkZvciBlYWNoIHRlc3QgY2FzZSwgcHJpbnQgaW4gYSBzaW5nbGUgbGluZSB0aGUgbWF4aW11bSBudW1iZXIgb2YgYnVyZ2VycyBIb21lciBjYW4gZWF0IHdpdGhvdXQgaGF2aW5nIGJlZXIuIElmIGhvbWVyIG11c3QgaGF2ZSBiZWVyLCB0aGVuIGFsc28gcHJpbnQgdGhlIHRpbWUgaGUgZ2V0cyBmb3IgZHJpbmtpbmcsIHNlcGFyYXRlZCBieSBhIHNpbmdsZSBzcGFjZS4KIEl0IGlzIHByZWZlcmFibGUgdGhhdCBIb21lciBkcmlua3MgYXMgbGl0dGxlIGJlZXIgYXMgcG9zc2libGUuPC9wPgo8aDM+U2FtcGxlIElucHV0PC9oMz4KPHByZSBjbGFzcz0="brush:java;">3 5 54 3 5 55

Sample Output

18
17

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 main(){ int m,n,t,x1,y1,temp; while(scanf("%d%d%d",&m,&n,&t)!=EOF){ int flag=0,mint=10000; if(m>n){ temp=m;m=n;n=temp; } int x=t/m,y=0; for(;x>=0;){ if(t==m*x+n*y){ printf("%d\n",x+y);flag=1;break; } else if((t-m*x-n*y)%n!=0&&(t-m*x-n*y)/n==0){ if(t-m*x-n*y
     
     



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇hdu 1394 Minimum Inversion Numb.. 下一篇HDOJ 4349 DP?

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: