Codeforces 598E Chocolate Bar (dp)
来源:互联网 发布:剪音乐的软件 编辑:程序博客网 时间:2024/06/06 00:54
@(K ACMer)
题意:
给你一个
分析:
很容易定义一个
也很容易设置转移,分为对切水平切和竖直切两种情况来转移.
水平切,造成成的消耗是
竖直切道理同水平切.
#include <iostream>#include <cstdio>#include <cstring>#include <set>#include <map>#include <stack>#include <vector>#include <string>#include <queue>#include <cstdlib>#include <cmath>#include <algorithm>using namespace std;typedef pair<int, int> pii;typedef unsigned long long ll;typedef vector<int> vi;#define xx first#define yy secondconst int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 41;int t, n, k, m, ans;int dp[31][31][50];int dfs(int x, int y, int num) { if (num == 0 || x * y == num) return 0; int mins = INF; if (dp[x][y][num]) return dp[x][y][num]; for (int i = 1; i < x; i++) { if (i * y >= num - (x - i) * y) { mins = min(dfs(i, y, num) + y * y, mins); mins = min(dfs(i, y, num - (num >= (x - i) * y ? (x - i) * y : 0)) + y * y, mins); } } for (int j = 1; j < y; j++) { if (j * x >= num - (y - j) * x) { mins = min(dfs(x, j, num) + x * x, mins); mins = min(dfs(x, j, num - ( num >= (y - j) * x ? (y - j) * x : 0)) + x * x, mins); } } return dp[x][y][num] = mins;}int main(void){ cin >> t; while (t--) { //cin >> n >> m >> k; scanf("%d%d%d", &n, &m, &k); printf("%d\n", dfs(n, m, k)); } return 0;}
0 0
- Codeforces 598E Chocolate Bar (dp)
- Codeforces 598E:Chocolate Bar(DP)
- Codeforces 598E Chocolate Bar
- Codeforces 598E:Chocolate Bar
- Codeforces 598E Chocolate Bar
- Codeforces 598E Chocolate Bar 【区间dp + 打表】
- CodeForces 598E Chocolate Bar(DP|记忆化搜索)
- Codeforces Problem 598E - Chocolate Bar
- Educational Codeforces Round 1 E.Chocolate Bar(DP)
- Educational Codeforces Round 1 E Chocolate Bar(dp)
- Coderforce 598 E. Chocolate Bar(DP,记忆化搜索)
- CF 598 E. Chocolate Bar dp题的要害是什么呢?
- 【Educational Codeforces Round 1E】【动态规划-多维DP】Chocolate Bar 矩形巧克力掰开吃的最小成本
- Educational Codeforces Round 1 E. Chocolate Bar(记忆化搜索)
- Codeforces 617B Chocolate 【dp】
- 【dp】codeforces 83E
- codeforces-731E-dp
- Codeforces 748E dp
- office下载地址和破解教程
- IE盒子模型和标准W3C盒子模型
- 17个新手常见Python运行时错误
- linux配置oracle客户端,sqlplus、sqlldr、exp、imp
- 浅析深究什么是中间件
- Codeforces 598E Chocolate Bar (dp)
- 纸牌丰收之c++版本
- Linux平台Oracle多个实例启动
- OpenCV2:Mat属性type,depth,step
- 一些学习链接
- 安卓 利用videoView 播放资源文件 并且全屏播放 适用于闪屏页
- NP-完全性介绍
- Android 实现控件浮动效果
- Android实现字母索引查找地名、联系人(二)