POJ 1946 DP
折腾了一晚上 明天再写。。 2016.5.17 23:59 -> ->
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int f[31][101][101],n,e,d,ans=9999;
int main(){
scanf("%d%d%d",&n,&e,&d);
memset(f,0x3f,sizeof(f));
f[1][0][0]=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=d;j++)
for(int k=1;k<=e;k++){
for(int l=1;k-l*l>=0&&l<=j;l++)
f[i][j][k]=min(f[i][j][k],f[i][j-l][k-l*l]+1);
f[i+1][j][j]=min(f[i][j][k],f[i+1][j][j]);
}
for(int i=1;i<=e;i++) ans=min(ans,f[n][d][i]);
printf("%d",ans);
}
POJ 1946 DP的更多相关文章
- POJ 1946 Cow Cycling(抽象背包, 多阶段DP)
Description The cow bicycling team consists of N (1 <= N <= 20) cyclists. They wish to determi ...
- hdu 1513 && 1159 poj Palindrome (dp, 滚动数组, LCS)
题目 以前做过的一道题, 今天又加了一种方法 整理了一下..... 题意:给出一个字符串,问要将这个字符串变成回文串要添加最少几个字符. 方法一: 将该字符串与其反转求一次LCS,然后所求就是n减去 ...
- poj 1080 dp如同LCS问题
题目链接:http://poj.org/problem?id=1080 #include<cstdio> #include<cstring> #include<algor ...
- poj 1609 dp
题目链接:http://poj.org/problem?id=1609 #include <cstdio> #include <cstring> #include <io ...
- POJ 1037 DP
题目链接: http://poj.org/problem?id=1037 分析: 很有分量的一道DP题!!! (参考于:http://blog.csdn.net/sj13051180/article/ ...
- Jury Compromise POJ - 1015 dp (标答有误)背包思想
题意:从 n个人里面找到m个人 每个人有两个值 d p 满足在abs(sum(d)-sum(p)) 最小的前提下sum(d)+sum(p)最大 思路:dp[i][j] i个人中 和 ...
- poj 1485 dp
转自:http://www.cnblogs.com/kuangbin/archive/2011/11/12/2246407.html [题目大意] 一条公路上有n个旅馆,选出其中k个设置仓库,一个仓库 ...
- POJ 3017 DP + 单调队列 + 堆
题意:给你一个长度为n的数列,你需要把这个数列分成几段,每段的和不超过m,问各段的最大值之和的最小值是多少? 思路:dp方程如下:设dp[i]为把前i个数分成合法的若干段最大值的最小值是多少.dp转移 ...
- POJ 1661 DP
Help Jimmy Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11071 Accepted: 3607 Descr ...
随机推荐
- switch方法中使用数字区间
function getCategory(age) { var category = ""; switch (true) { case isNaN(age): category = ...
- vue-router的基本使用和配置
1.在main.js文件中引入相关模块以及组件及实例化vue对象配置选项路由及渲染App组件 默认设置如下: import Vue from 'vue' import App from './App' ...
- POJ3278——Catch That Cow
Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 114140 Accepted: 35715 ...
- Linux日期时间
#日期时间 echo '日期时间' datetime=$(date "+%Y-%m-%d %H:%M:%S") echo "$datetime"
- PAT 1060. Are They Equal
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered ...
- BZOJ 4044 Luogu P4762 [CERC2014]Virus Synthesis (回文自动机、DP)
好难啊..根本不会做..基本上是抄Claris... 题目链接: (bzoj)https://www.lydsy.com/JudgeOnline/problem.php?id=4044 (luogu) ...
- 协程,greenlet原生协程库, gevent库
协程简介 协程(coroutine),又称为微线程,纤程,是一种用户级的轻量级线程.协程拥有自己的寄存器上下文和栈. 协程调度切换时,将寄存器上下文和栈保存到其他地方,在切回来时,恢复之前保存的上下文 ...
- RaspberryPi3安装CentOS7教程
1.准备 Centos 7 AMR版镜像下载地址: http://mirror.centos.org/altarch/7/isos/armhfp/ 下载得到:CentOS-Userland-7-arm ...
- E - Period
For each prefix of a given string S with N characters (each character has an ASCII code between 97 a ...
- 洛谷—— P1379 八数码难题
https://daniu.luogu.org/problem/show?pid=1379 题目描述 在3×3的棋盘上,摆有八个棋子,每个棋子上标有1至8的某一数字.棋盘中留有一个空格,空格用0来表示 ...