Cow Cycling 动态规划
1552: Cow Cycling
时间限制(普通/Java):1000MS/10000MS 内存限制:65536KByte
总提交: 39 测试通过:20
描述
The cow bicycling team consists of N (1 <= N <= 20) cyclists. They wish to determine a race strategy which will get one of them across the finish line as fast as possible.
Like everyone else, cows race bicycles in packs because that's the most efficient way to beat the wind. While travelling at x laps/minute (x is always an integer), the head of the pack expends x*x energy/minute while the rest of pack drafts behind him using only x energy/minute. Switching leaders requires no time though can only happen after an integer number of minutes. Of course, cows can drop out of the race at any time.
The cows have entered a race D (1 <= D <= 100) laps long. Each cow has the same initial energy, E (1 <= E <= 100).
What is the fastest possible finishing time? Only one cow has to cross the line. The finish time is an integer. Overshooting the line during some minute is no different than barely reaching it at the beginning of the next minute (though the cow must have the energy left to cycle the entire minute). N, D, and E are integers.
输入
A single line with three integers: N, E, and D
输出
A single line with the integer that is the fastest possible finishing time for the fastest possible cow. Output 0 if the cows are not strong enough to finish the race.
样例输入
3 30 20
样例输出
7
提示
as shown in this chart:
leader E
pack total used this
time leader speed dist minute
1 1 5 5 25
2 1 2 7 4
3 2* 4 11 16
4 2 2 13 4
5 3* 3 16 9
6 3 2 18 4
7 3 2 20 4
* = leader switch
题意:有N头奶牛,每头奶牛的能量是E,现在有一个任务是跑完D圈,但是只要有一头奶牛完成这个任务就算通过。每次需要有一头奶牛领跑,其他的奶牛可以选择继续跟着跑或者离开队伍。领跑的奶牛能量
消耗是x*x laps/min,跟跑的能量消耗是x laps/min,然后让你计算最短需要多少时间完成任务。
题解:有N头奶牛,那么当N-1头奶牛都领跑过,那么最后一头奶牛去完成任务就成了。
状态:wxl[i][j][t],第i头奶牛跑 j 圈,消耗t能量所花费的最短时间。
状态转移方程:wxl[i+1][j][j]=min(wxl[i+1][j][j],wxl[i][j][t]);//换奶牛领跑不消耗时间 wxl[i][j+l][l*l+t]=min(wxl[i][j][t]+1,wxl[i][j+l][l*l+t]);
#include "bits/stdc++.h"
using namespace std;
#define INF 0x3f3f3f3f
int wxl[][][];//存状态,第i头奶牛跑j圈,第i头奶牛消耗t所花费的最小时间
int main()
{
ios::sync_with_stdio(false);
cin.tie();cout.tie();//输入输出加速
int n,e,d,i,j,t,l,sum=INF;
cin>>n>>e>>d;
for(i=;i<=n;++i)for(j=;j<=d;++j)for(t=;t<=e;++t)wxl[i][j][t]=INF;
wxl[][][]=;
for(i=;i<=n;++i)for(j=;j<=d;++j)for(t=;t<=e;++t)
{
if(wxl[i][j][t]==INF)continue;
for(l=;l+j<=d&&l*l+t<=e;++l)wxl[i][j+l][l*l+t]=min(wxl[i][j][t]+,wxl[i][j+l][l*l+t]);
wxl[i+][j][j]=min(wxl[i+][j][j],wxl[i][j][t]);//换奶牛领跑不消耗时间
}
for(i=;i<=e;++i)sum=min(sum,wxl[n][d][i]);
cout<<sum<<endl;//当完不成任务时输出wxl[n][d][0];
}
//状态转移方程是wxl[i][t+l][l*l+t]=min(wxl[i][j][t]+1,wxl[i][t+l][l*l+t]);wxl[i+1][j][j]=min(wxl[i+1][j][j],wxl[i][j][t]);
Cow Cycling 动态规划的更多相关文章
- [USACO2002][poj1946]Cow Cycling(dp)
Cow CyclingTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 2468 Accepted: 1378Description ...
- POJ 1946 Cow Cycling
Cow Cycling Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 2516 Accepted: 1396 Descr ...
- POJ3267——The Cow Lexicon(动态规划)
The Cow Lexicon DescriptionFew know that the cows have their own dictionary with W (1 ≤ W ≤ 600) wor ...
- POJ3176——Cow Bowling(动态规划)
Cow Bowling DescriptionThe cows don't use actual bowling balls when they go bowling. They each take ...
- POJ - 3176 Cow Bowling 动态规划
动态规划:多阶段决策问题,每步求解的问题是后面阶段问题求解的子问题,每步决策将依赖于以前步骤的决策结果.(可以用于组合优化问题) 优化原则:一个最优决策序列的任何子序列本身一定是相当于子序列初始和结束 ...
- POJ 1946 Cow Cycling(抽象背包, 多阶段DP)
Description The cow bicycling team consists of N (1 <= N <= 20) cyclists. They wish to determi ...
- 【BZOJ3939】[Usaco2015 Feb]Cow Hopscotch 动态规划+线段树
[BZOJ3939][Usaco2015 Feb]Cow Hopscotch Description Just like humans enjoy playing the game of Hopsco ...
- PKU 3267 The Cow Lexicon(动态规划)
题目大意:给定一个字符串和一本字典,问至少需要删除多少个字符才能匹配到字典中的单词序列.PS:是单词序列,而不是一个单词 思路: ...
- poj 3267 The Cow Lexicon (动态规划)
The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8167 Accepted: 3845 D ...
随机推荐
- ORACLE——EXTRACT() 截取日期时间的函数使用
1.截取日期的 年: --使用方法 EXTRACT(YEAR FROM DATE) SQL> SELECT EXTRACT( YEAR FROM SYSDATE ) FROM DUAL; --结 ...
- 20175211 2017-2018-2 《Java程序设计》第六周学习记录(2)
目录 1.File类 2.FilenameFilter接口 3.输入输出流 4.使用Scanner解析文件 参考资料 <Java 2实用教程>第10章 输入.输出流 1.File类 常用方 ...
- Netflix是怎样运行的(极度简化版)— 每次点击播放按钮背后的复杂东西
Netflix是怎样运行的(极度简化版)- 每次点击播放按钮背后的复杂东西 本文摘译自 How Netflix works: the (hugely simplified) complex stuff ...
- cocos 水果机,老Tiger虎机流水灯,博彩大转盘效果
原(http://www.cnblogs.com/zisou/p/cocos2d-xZhuanpan.html) 博彩大转盘,转盘抽奖的小系统,这是一个很有意思的游戏模块,游戏中增加这样一些趣味的小模 ...
- nginx如何调用php
nginx如何调用php 采用nginx+php作为webserver的架构模式,在现如今运用相当广泛.然而第一步需要实现的是如何让nginx正确的调用php.由于nginx调用php并不是如同调用一 ...
- poj1456
题目大意:给定一些物品以及他们的价值和时间w.t,表示物品在时间t内售出能得到w 的价值,一天只能出售一件物品,求最大利润: 非常有意思的一道并查集的思想题 首先以价值为关键字排序,类似于贪心的思想, ...
- 求方差分析与两样本T检验 区别
方差分析与两样本T检验. 1.首先可以看到方差分析(ANOVA)包含两样本T检验,把两样本T检验作为自己的特例.因为ANOVA可以比较多个总体的均值,当然包含两个总体作为特例.实际上,T的平方就是F统 ...
- [游戏开发日志]Windows下Cocos2d-x 3.14环境搭建
总介绍 我们小组使用的是cocos2d-x的游戏开发引擎,因此在所有开发工作之前,我们需要对这个引擎进行环境的搭建. 搭建过程 VS2013的下载和安装 VS只是作为一个开发环境而已,简单来说就是敲代 ...
- php读取文件使用redis的pipeline(管道)导入大批量数据
需求:需要做一个后台上传TXT文件,读取其中的内容,然后导入redis库中.要求速度快,并且支持至少10W以上的数据,而内容也就一个字段存类似openid和QQ 传统做法:我一开始做的时候就老套路,遍 ...
- Linux的DNS配置1-DNS入门
1.DNS简介 1)什么是“DNS”? DNS,简单地说,就是Domain Name System,翻成中文就是“域名系统” 2)DNS有什么用途? 在一个TCP/IP架构的网络(例如Internet ...