UVA 10465 —— 完全背包
来源:互联网 发布:焦土抗战 知乎 编辑:程序博客网 时间:2024/03/29 15:31
10465 - Homer Simpson
Time limit: 3.000 seconds
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 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
题意是一个人要在时间t内吃汉堡,有两种汉堡,需要的时间分别为m和n,问你最多能吃多少个,如果其中有间隔输出间隔时间。
思路:只有两件物品的完全背包。/*ID: xinming2PROG: stall4LANG: C++*/#include <cstdio>#include <cmath>#include <algorithm>#include <iostream>#include <cstring>#include <map>#include <string>#include <stack>#include <cctype>#include <vector>#include <queue>#include <set>#include <utility>#include <cassert>using namespace std;///#define Online_Judge#define outstars cout << "***********************" << endl;#define clr(a,b) memset(a,b,sizeof(a))#define lson l , mid , rt << 1#define rson mid + 1 , r , rt << 1 | 1#define mk make_pair#define FOR(i , x , n) for(int i = (x) ; i < (n) ; i++)#define FORR(i , x , n) for(int i = (x) ; i <= (n) ; i++)#define REP(i , x , n) for(int i = (x) ; i > (n) ; i--)#define REPP(i ,x , n) for(int i = (x) ; i >= (n) ; i--)const int MAXN = 10000 + 50;const int sigma_size = 26;const long long LLMAX = 0x7fffffffffffffffLL;const long long LLMIN = 0x8000000000000000LL;const int INF = 0x7fffffff;const int IMIN = 0x80000000;#define eps 1e-8const int mod = (int)1e9 + 7;typedef long long LL;const LL MOD = 1000000007LL;const double PI = acos(-1.0);typedef pair<int , int> pi;#define Bug(s) cout << "s = " << s << endl;///#pragma comment(linker, "/STACK:102400000,102400000")int n , m , t;int dp[MAXN];int main(){ while(~scanf("%d%d%d" , &m , &n, &t )) { clr(dp , -1); dp[0] = 0; for(int i = m ; i <= t ; i++) { if(dp[i - m] != -1)dp[i] = max(dp[i] , dp[i - m] + 1); } for(int i = n ; i <= t ; i++) { if(dp[i - n] != -1)dp[i] = max(dp[i] , dp[i - n] + 1); } if(dp[t] != -1)printf("%d\n" , dp[t]); else { for(int i = t ; i >= 0 ; i--) { if(dp[i] != -1) { printf("%d %d\n" , dp[i], t - i); break; } } } } return 0;}
- UVA 10465 —— 完全背包
- uva 10465 (完全背包)
- UVA 10465 Homer Simpson(dp + 完全背包)
- 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(DP完全背包)
- UVa 10465 Homer Simpson(DP 完全背包)
- [UVA]10465 - Homer Simpson(完全背包问题)
- UVA 10465 Homer Simpson(完全背包)
- uva 10465 Homer Simpson (完全背包)
- UVA 674完全背包
- uva 10306(完全背包)
- uva 10280(完全背包)
- dp—完全背包
- Uva 147 Dollars 完全背包
- windows下的shellcode剖析浅谈
- iOS开发-组合动画CAAnimationGroup
- Hbase shell详情
- DataContractJsonSerializer 类 操作json类型数据
- unix深入篇
- UVA 10465 —— 完全背包
- shell 脚本每隔一段时间打印当前系统时间
- 程序员遇到Bug的30种反应
- Kprobes源码分析----kprobe的注册
- 【使用JSOUP实现网络爬虫】从元素抽取属性,文本和HTML
- Linux下Openssl的安装全过程
- dll中启动shellcode卸载自身dll模块
- 转一篇杂谈:技术真的就不是那么重要了
- hdu 3081&hdu 3277 (最大流)