UVa 11900 - Boiled Eggs
来源:互联网 发布:在淘宝某店被限制购买 编辑:程序博客网 时间:2024/05/16 06:43
題目:用微波爐煮雞蛋,給你每個雞蛋的重量,微波爐能放的雞蛋個數和總重有限制,
問最多能煮幾個雞蛋。
分析:dp,01背包。赤果果給的01背包。
設計狀態:f(n)為總質量為n時,最大的雞蛋個數;
狀態轉移:f(i)=max(f(i-m[j])+1,f(i-1));
說明:╮(╯▽╰)╭。
#include <cstring>#include <cstdio>int dp[303],m[33];int main(){int T, n, P, Q;while (~scanf("%d",&T))for (int t = 1; t <= T; ++ t) {scanf("%d%d%d",&n,&P,&Q);for (int i = 0; i < n; ++ i)scanf("%d",&m[i]);memset(dp, 0, sizeof(dp));for (int i = 0; i < n; ++ i)for (int j = Q; j >= m[i]; -- j)if (dp[j] < dp[j-m[i]]+1)dp[j] = dp[j-m[i]]+1;if (dp[Q] > P)dp[Q] = P;printf("Case %d: %d\n",t,dp[Q]);} return 0;}
0 0
- UVa 11900 - Boiled Eggs
- lightOJ 1227 - Boiled Eggs
- light oj 1227 - Boiled Eggs
- Lightoj1227——Boiled Eggs(贪心)
- eggs
- Python Eggs
- Painting Eggs
- two eggs
- Eggs简介
- Drop Eggs
- Eggs Dropping puzzle(2 eggs, 100 floors)
- What is Easter Eggs?
- Permission denied: ... .python-eggs
- [转]install Python eggs
- B. Painting Eggs
- Eggs and Egg Info
- python-eggs异常解决方法
- eggs(递归)
- 数学之美
- Makefile相关知识
- Tomcat启动报Error listenerStart错误
- JAVA学习之 将xml导入到数据库
- 使用Nexus搭建Maven私服
- UVa 11900 - Boiled Eggs
- QuartZ Cron表达式
- 百度消息推送SDK探究(并附上最简推送Demo)
- Java 多维数组遍历
- mysql 导入导出整个库
- linux 常用命令
- GIMP 工具
- 12以内20以内100以内的阶乘方法
- 一个Filter配置多个url-pattern