hdu 4563

  • 把每个命令走的距离抽象成完全背包
  • 枚举最后一个不是整点走完的命令
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <set>
#include <queue> using namespace std; typedef long long LL;
const double N = -1e9; double DP[105];
int xx[105],yy[105]; double cal(double t,int v)
{
return -9.8*t*t/2.0+v*t;
} double check(int x,int n,int L)
{
for(int i = 0; i <= 100; i++)
DP[i] = N;
DP[0] = 0;
for(int i = 0; i < n; i++) //选第几个命令
{
if(i == x) continue;
for(int j = L; j >= 0; j--) //到距离j
{
for(int k = 0; k <= L/xx[i]; k++) //命令i走k秒
{
if(j >= k*xx[i])
{
DP[j] = max(DP[j],DP[j-k*xx[i]]+cal(k,yy[i]));
}
}
}
}
double ans = N;
for(int i = 0; i <= L; i++)
{
ans = max(ans,DP[i]+cal(1.0*(L-i)/xx[x],yy[x])); //枚举最后一个命令是从哪个
}
return ans;
} void solve(int cnt)
{
int nn,L; scanf("%d %d",&nn,&L);
for(int i = 0; i < nn; i++)
{
scanf("%d %d",&xx[i],&yy[i]);
}
double ans = N;
for(int i = 0; i < nn; i++)
{
ans = max(ans,check(i,nn,L)); //枚举最后一个命令是哪个,因为只有最后一个命令不是整点到达
}
printf("Case %d: %.3f\n",cnt,ans);
} int main(void)
{
int t,cnt = 1;
scanf("%d",&t);
while(t--)
solve(cnt++);
return 0;
}

hdu 4563的更多相关文章

  1. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  3. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  4. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  5. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  6. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  7. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  8. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

  9. hdu 4329

    problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R ...

随机推荐

  1. input输入内容成可点击状态

    <!DOCTYPE html> <html> <head> <script src="//code.jquery.com/jquery-1.9.1. ...

  2. Linux 实用指令(9)--进程管理

    目录 进程管理 1 进程的基本介绍 2 显示系统执行的进程 2.1 说明: 2.2 ps指令详解 2.3 应用实例 3 终止进程kill和killall 3.1 介绍 3.2 基本语法 3.3 常用选 ...

  3. 笔记:Python防止SQL注入

    非安全的方式,使用动态拼接SQL 输入' or 1 = 1 or '1 sql ="""SELECT * FROM goods WHERE name = '%s';&qu ...

  4. SpringBoot Redis 订阅发布

    一  配置application.yml spring: redis: jedis: pool: max-active: 10 min-idle: 5 max-idle: 10 max-wait: 2 ...

  5. 解析Spring第一天

    目的:了解spring框架中的注解 前言:同样是使用idea创建一个普通的maven工程(如何创建一个普通的Maven工程可以参考mybatis入门第一天的详解). 项目结构: 代码编辑: 在项目中引 ...

  6. kaptcha 实现验证码

    依赖 <dependency> <groupId>com.github.penggle</groupId> <artifactId>kaptcha< ...

  7. 概率dp——hdu4089推公式+循环迭代

    迭代是化简公式的常用技巧 dp[i][j]表示队伍中有i人,tomato排在第j位出现情况2的概率,那么先推出公式再进行简化 dp[i][1]=p21*dp[i][i] + p41 j<=k : ...

  8. web移动端rem的适配

    ** 需求: 随着移动端设备的变化,内容也跟着变化.**先来说说rem单位,以rem为单位,其大小是根据根元素(html标签)的字体大小来判断的,      如 html的font-size:100p ...

  9. exit与return的区别

    ===========================PHP的解释=========================================================== return ...

  10. Assert(断言) 的用法

    Assert Assert是断言的意思,头文件为assert.h, assert是一个宏 功 能: 测试一个条件并可能使程序终止 用 法: void assert(int test); 在单元测试中经 ...