poj 1964 Cow Cycling(dp)
/*
一开始想的二维的 只维护第几只牛还有圈数
后来发现每只牛的能量是跟随每个状态的
所以再加一维 f[i][j][k]表示第i只牛 领跑的j全 已经消耗了k体力
转移的话分两类
1.换一只牛领跑 那么就从f[i][j][k]转移到f[i+1][j][j]
2.不换 那就枚举i领跑几圈l f[i][j-l][k-l*l]转移到f[i][j][k] 时间++
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 110
using namespace std;
int n,d,e,f[maxn][maxn][maxn],ans=0x7fffffff;
int main()
{
scanf("%d%d%d",&n,&e,&d);
memset(f,/,sizeof(f));
f[][][]=;
for(int i=;i<=n;i++)
for(int j=;j<=d;j++)
for(int k=;k<=e;k++)
{
for(int l=;l<=d;l++)//这只领跑几圈
{
if(j<l||k<l*l)continue;
f[i][j][k]=min(f[i][j][k],f[i][j-l][k-l*l]+);
}
f[i+][j][j]=min(f[i+][j][j],f[i][j][k]);//换一只牛领跑
}
for(int i=;i<=e;i++)
ans=min(ans,f[n][d][i]);
printf("%d\n",ans);
return ;
}
poj 1964 Cow Cycling(dp)的更多相关文章
- [USACO2002][poj1946]Cow Cycling(dp)
Cow CyclingTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 2468 Accepted: 1378Description ...
- 【POJ 3071】 Football(DP)
[POJ 3071] Football(DP) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4350 Accepted ...
- Poj 3613 Cow Relays (图论)
Poj 3613 Cow Relays (图论) 题目大意 给出一个无向图,T条边,给出N,S,E,求S到E经过N条边的最短路径长度 理论上讲就是给了有n条边限制的最短路 solution 最一开始想 ...
- POJ 3858 Hurry Plotter(DP)
Description A plotter is a vector graphics printing device that connects to a computer to print grap ...
- POJ - 2385 Apple Catching (dp)
题意:有两棵树,标号为1和2,在Tmin内,每分钟都会有一个苹果从其中一棵树上落下,问最多移动M次的情况下(该人可瞬间移动),最多能吃到多少苹果.假设该人一开始在标号为1的树下. 分析: 1.dp[x ...
- POJ 3270 Cow Sorting(置换群)
题目链接 题意 : N头牛,每个牛的坏脾气都有一个值,每个值都不相同,把这个值按照从小到大排序,如果两个值交换,那么会花掉这两个值之和的时间,让你花最少的时间将每个值从小到大排好序,求最小的总时间. ...
- POJ 3267:The Cow Lexicon(DP)
http://poj.org/problem?id=3267 The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submi ...
- poj 2184 Cow Exhibition(dp之01背包变形)
Description "Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - ...
- poj 3176 Cow Bowling(dp基础)
Description The cows don't use actual bowling balls when they go bowling. They each take a number (i ...
随机推荐
- extjs中combobox默认显示第一个值
在进入页面时往往用户希望页面能够显示默认的内容,但是页面中会存在一些选项通过用户选择之后才会加载相应的内容.在这篇文章里面介绍了如何去设置页面中默认的内容,如combobox默认显示第一个值. 页面: ...
- jquery animate函数实现
jquery animate 函数 实现动画效果 参数一 比如高度宽度 之类的:'-=50' 参数二 速度之类 <html xmlns="http://www.w3.org/1999/ ...
- Codeforces Round #313 A Currency System in Geraldion
A Currency System in Geraldion Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64 ...
- Oracle归档日志定时删除任务
1.在Oracle账号下,创建归档日志删除文件del_arch.sh 文件位置:/home/oracle/crontabOra,内容如下: #!/bin/bash LOG_DIR=/home/orac ...
- 记 tower.im 的一次重构
原文in here: http://outofmemory.cn/wr?u=http%3A%2F%2Fblog.mycolorway.com%2F2013%2F05%2F01%2Ftower-refa ...
- 转:hadoop知识整理
文章来自于:http://tianhailong.com/hadoop%E7%9F%A5%E8%AF%86%E6%95%B4%E7%90%86.html 按照what.how.why整理了下文章,帮助 ...
- 【手机安全卫士01】项目Splash页面的开发与设计
首先建立一个安卓的项目,然后修改manifest.xml文件,修改应用程序的logo和显示名称,效果图如下: 对应的代码如下: <?xml version="1.0" enc ...
- python里的Join函数
用法是将数组里的每个元素用字符连接起来 import string string.join(["aaaa", "bbb"]) 或者: from string i ...
- 王学长的LCT标程
善良的王学长竟然亲自打了一遍QAQ好感动QAQ #include<iostream> #include<cstdio> #include<cmath> #inclu ...
- T-SQL中return 返回语句学习
return命令用于结束当前程序的执行,返回到上一个调用它的程序或其他程序,其语法格式如下: return 整数值或变量 return语句要指定返回值,如果没有指定返回值,SQL Server系统 ...