题目链接

直接拿来当贪心做了=_=,然后就懵逼了

动态规划,本弱真没想到=_=

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const double eps = 0.000001;
const int INF = 0xffffff;
int station[];
double dp[];
int l, n, c, t, vr, vt1, vt2;
double get_time(int s, int tempc)
{
double gtime = ;
if(s > tempc)
{
gtime += 1.0 * tempc / vt1;
gtime += (s - tempc) * 1.0 / vt2;
}
else
{
gtime += s * 1.0 / vt1;
}
return gtime;
}
int is_chong(int s, int tempc)
{
double chong_time = t + get_time(s, c);
double not_chong_time = get_time(s, tempc);
if(not_chong_time - chong_time > eps)
return ;
return ;
}
double get_min(double x, double y)
{
if(x - y > eps)
return y;
return x;
}
int main()
{
while(scanf("%d", &l) != EOF)
{
scanf("%d%d%d", &n, &c, &t);
scanf("%d%d%d", &vr, &vt1, &vt2);
for(int i = ; i <= n; i++)
scanf("%d", &station[i]);
station[n + ] = l;
double rtime = 1.0 * l / vr;
station[] = ;
dp[] = ;
for(int i = ; i <= n + ; i++)
{
dp[i] = INF;
for(int j = i - ; j >= ; j--)
{
double tempTime = ;
int s = station[i] - station[j];
if(s > c)
{
tempTime = 1.0 * c / vt1;
tempTime += (s - c) * 1.0 / vt2;
}
else
tempTime = s * 1.0 / vt1;
if(j)
tempTime += t;
dp[i] = get_min(dp[i], dp[j] + tempTime);
}
/*
int s = station[i] - station[i - 1];
if(s > tempc)
{
gtime += 1.0 * tempc / vt1;
gtime += (s - tempc) * 1.0 / vt2;
tempc = 0;
}
else
{
gtime += s * 1.0 / vt1; // 不知道什么时候手贱,这里把s写成了c,浪费了半个小时
tempc = tempc - s;
}
if(is_chong(station[i + 1] - station[i], tempc))
{
gtime += t;
tempc = c;
}
*/
}
//gtime += get_time(l - station[n], tempc);
if(dp[n + ] - rtime > eps)
printf("Good job,rabbit!\n");
else
printf("What a pity rabbit!\n");
}
return ;
}

HD2059龟兔赛跑(DP)的更多相关文章

  1. 龟兔赛跑(DP)

    龟兔赛跑 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  2. hdoj 2059 :龟兔赛跑 (DP)[转]

      转的别人的找了很多就这个比较好理解.   Problem Description 据说在很久很久以前,可怜的兔子经历了人生中最大的打击——赛跑输给乌龟后,心中郁闷,发誓要报仇雪恨,于是躲进了杭州下 ...

  3. hdu2059 龟兔赛跑 DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2059 虽然 知道是DP ,刚开始一直没有想出状态转移方程. 刚开始的思路就是定义dp[i]表示到达第i ...

  4. HDU 2056 龟兔赛跑 (DP)

    题意:见题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2059 解题报告:以前一直没看出来这题是个DP题,知道是DP题就简单了 .首先要把起点和终点看成 ...

  5. hdu 2059 龟兔赛跑 (dp)

    /* 把起点和终点比作加油站,那总共同拥有n+2个加油站了, 每次都求出从第0个到第j个加油站(j<i)分别在加满油的情况下到第i个加油站的最短时间dp[i], 终于的dp[n+1]就是最优解了 ...

  6. 8-11-Exercise

    链接:第四次小练 A.POJ 3094   Quicksum 水题中的水题啊~ 直接上代码: #include <iostream> #include <cstdio> #in ...

  7. 【巧妙消维DP】【HDU2059】龟兔赛跑

    龟兔赛跑 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  8. hdu 2059 龟兔赛跑(dp)

    龟兔赛跑 Problem Description 据说在很久很久以前,可怜的兔子经历了人生中最大的打击——赛跑输给乌龟后,心中郁闷,发誓要报仇雪恨,于是躲进了杭州下沙某农业园卧薪尝胆潜心修炼,终于练成 ...

  9. HDU 2059 龟兔赛跑(超级经典的线性DP,找合适的j,使得每个i的状态都是最好的)

    龟兔赛跑 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

随机推荐

  1. .Net下一个类型转换神器

    引言 类型转换经常遇到,最常用的应该是string类型转换为其它基元类型,常见于http参数类型转换.Convert静态类的Convert.ChangeType()方法可以把实现IConvertibl ...

  2. PHP+mysql数据库开发搜索功能:中英文分词+全文检索(MySQL全文检索+中文分词(SCWS))

    PHP+mysql数据库开发类似百度的搜索功能:中英文分词+全文检索 中文分词: a)   robbe PHP中文分词扩展: http://www.boyunjian.com/v/softd/robb ...

  3. 三言两语聊Python模块–文档测试模块doctest

    doctest是属于测试模块里的一种,对注释文档里的示例进行检测. 给出一个例子: splitter.pydef split(line, types=None, delimiter=None): &q ...

  4. [POJ1284]Primitive Roots(原根性质的应用)

    题目:http://poj.org/problem?id=1284 题意:就是求一个奇素数有多少个原根 分析: 使得方程a^x=1(mod m)成立的最小正整数x是φ(m),则称a是m的一个原根 然后 ...

  5. poj 1698 Alice‘s Chance

    poj 1698  Alice's Chance 题目地址: http://poj.org/problem?id=1698 题意: 演员Alice ,面对n场电影,每场电影拍摄持续w周,每周特定几天拍 ...

  6. 屠龙之路_战胜狮身人面怪物_SecondDay

    第二天,少年们跋山涉水来到了恶龙山的山脚.前面有一座迷宫,守卫迷宫的是一只狮身人面的怪物,它出一个谜语让少年们猜,如果屠龙团猜不出答案就会被吃掉(如果你能猜出来,我就让你--),它问:"软件 ...

  7. [团队项目]Github生成燃尽图的方式

    经过一晚上折腾,终于算是把linux上成功生成了我们团队项目的燃尽图,效果还是不错,在过程中又发现了另一种生成燃尽图的方式,也是基于一个开源项目. 1.准备: 首先你的项目一定要有milestone. ...

  8. [转]SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)

    原文地址:http://blog.csdn.net/zhshulin/article/details/37956105#comments 使用SSM(Spring.SpringMVC和Mybatis) ...

  9. iOS开发中的错误整理,iOS9之后的UIWindow(TopWindow)以及UIWindow与statusBar的关系

    iOS9之后的UIWindow的问题(TopWindow),以及UIWindow与statusBar之间的联系 1.出现的问题 iOS9之后UIWindow必须要指定一个根控制器,不然会报错!iOS9 ...

  10. bzoj1051

    就是一个tarjan #include<iostream> #include<stack> #include<cstdio> using namespace std ...