CodeForces 106C Buns (01beoba)
来源:互联网 发布:pl sql developer下载 编辑:程序博客网 时间:2024/05/23 07:24
http://codeforces.com/problemset/problem/540/B
题意:第一行,n, m, c0, d0 ,n,表示面的总数,m表示下边数据有m行,c0表示做一个馒头需要c0的面,d0表示一个馒头的价值是d0;
ai, bi, ci,di, ai表示做第i种包子一个有的馅,bi表示做第i种包子一个需要bi的陷,ci表示做第i种包子一个需要ci的面,di表示一个该种包子的价值是di;
思路:01背包
#include <iostream>#include <cmath>#include <cstring>#include <algorithm>#include <queue>#include <cstdio>using namespace std;#define N 110#define INF 0x3f3f3f3f#define met(a, b) memset (a, b, sizeof (a))int dp[N*10];int main (){ int n, m, w[N], h[N], v[N], a, b, x, y, z, t; while (scanf ("%d %d %d %d", &n, &m, &a, &b) != EOF) { met (dp, 0); w[0] = n/a;///可以做的馒头数 h[0] = a;///一个馒头需要的面 v[0] = b;///每个馒头的价值 for (int i=1; i<=m; i++) { scanf ("%d %d %d %d", &x, &y, &z, &t); w[i] = x/y;///可以做的包子数 h[i] = z;///一个包子需要的面 v[i] = t;///每个包子的价值 } for (int i=0; i<=m; i++) { for (int j=1; j<=w[i]; j++) { for (int k=n; k>=h[i]; k--) dp[k] = max (dp[k], dp[k-h[i]]+v[i]); } } printf ("%d\n", dp[n]); } return 0;}
1 0
- CodeForces 106C Buns (01beoba)
- codeforces 106C Buns
- Codeforces 106C Buns
- Codeforces 106 C Buns【多重背包】
- Codeforces 106C Buns 【0-1背包】
- Codeforces--106C--Buns(背包)
- codeforces 106C. Buns【多重背包】
- Codeforces 106 C Buns【多重背包】
- CodeForces 106C Buns 多重背包
- CodeForces 106C Buns (多重背包)
- CF 106C Buns
- Buns CodeForces
- CF 106C Buns 再解
- Buns
- Codeforces 394D Physical Education and Buns
- Codeforces 394D Physical Education and Buns(暴力)
- Codeforces 394D Physical Education and Buns 胡搞
- CF Buns (01背包问题)
- 3.5模拟赛题解
- 神经网络的简单数学解释
- SpringAop
- mac使用git管理Github
- [重拾]深入理解gulp自动化
- CodeForces 106C Buns (01beoba)
- Java的反射机制详解
- Android开发问题汇总–持续更新
- Threading Performance 2
- linux学习笔记
- LeetCode OJ刷题历程——Remove Nth Node From End of List
- C++扬帆远航——1
- 【C#】面向对象基础—属性、方法、结构
- TP整合微信遇到的一系列问题