uva 10465 - Homer Simpson(贪心)
2015-01-22 19:33
1501 查看
Homer SimpsonTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
SubmitStatus
Description
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/2ea975a8d421ce3226c46b0946fd5932.png)
m, n, t (0 < m,n,t < 10000). Input is terminated by EOF.
beer as possible.
& %llu
SubmitStatus
Description
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/2ea975a8d421ce3226c46b0946fd5932.png)
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 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 littlebeer as possible.
Sample Input
3 5 54 3 5 55
Sample Output
18 17
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<string> #include<algorithm> #include<cstdlib> #include<set> #include<queue> #include<stack> #include<vector> #include<map> #define N 100010 #define Mod 10000007 #define lson l,mid,idx<<1 #define rson mid+1,r,idx<<1|1 #define lc idx<<1 #define rc idx<<1|1 const double EPS = 1e-11; const double PI = acos(-1.0); typedef long long ll; const int INF=1000010; using namespace std; int n,m,t; int main() { //freopen("test.in","r",stdin); while(cin>>m>>n>>t) { int ans2=t,ans=0,ans1=0; for(int i=0; i<=t/m; i++) { int x=(t-i*m)/n; if((i*m+x*n!=t)) { if((t-i*m-x*n)<ans2) { ans=i+x; ans2=t-i*m-x*n; } else if((t-i*m-x*n)==ans2&&ans<i+x) ans=i+x; } if(ans1<(i+x)&&(i*m+x*n==t)) ans1=i+x; } if(ans1) { printf("%d\n",ans1); continue; } printf("%d",ans); printf(" %d\n",ans2); } return 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(DP 全然背包)
- 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