uva 10465 - Homer Simpson(贪心)
来源:互联网 发布:阿里云可用区什么意思 编辑:程序博客网 时间:2024/06/01 08:21
Homer SimpsonTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
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.
Description
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
#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|1const 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;}
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
- POJ 1942 Paths on a Grid (组合数学)
- 数据库系统的三级模式结构
- 点击LinearLayout使用selector改变TextView字体颜色
- springmvc+spring+hibernate 整合 annotation(全注解)方式
- 平面点集的最小包围圆 hdu 3932
- uva 10465 - Homer Simpson(贪心)
- BZOJ 3876 AHOI2014 支线剧情 费用流
- Eclipse中Velocity插件安装
- 回顾BufferedInputStream-int read(byte[] buffer)BufferedOutputStream-void write(byte[] buff ,int offset
- Java入门--认识理解Java中native方法
- 初窥——进入公司后的JAVA_WEB开发04_锚链接使用
- mysql insert time
- Android Studio中so包的导入
- Oracle分区表 (Partition Table) 的创建及管理