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. jq页面换肤效果

    <!DOCTYPE html> <html lang="en"> <head> <script src="http://code ...

  2. [CERC2017]Gambling Guide

    题目 看起来非常随机游走,但是由于我们可以停在原地,所以变得不是非常一样 设\(f_x\)表示从\(x\)到\(n\)的期望距离 如果我们提前知道了\(f\),那么我们随机到了一张到\(y\)的车票, ...

  3. 2018今日头条湖北省赛【D】

    [题目链接]https://www.nowcoder.com/acm/contest/104/C 不知道这题为啥没过.队友现场推的都是对的..233333好像代码写的有问题,下来就很恼火. 题意大概就 ...

  4. CentOS7开放防火墙端口

    ~~~~~~~~~~~~开放某个端口~~~~~~~~~~~~firewall-cmd --zone=public --add-port=6669/tcp --permanentfirewall-cmd ...

  5. echarts数据变了不重新渲染,以及重新渲染了前后数据会重叠渲染的问题

    1.echarts数据变了但是视图不重新渲染 新建Chart.vue文件 <template>  <p :id="id" :style="style&q ...

  6. java Future && Guava Future

    ### java future Runnable的任务是没有返回值,也不能抛出异常的java.util.concurrent.Callable接口,可以返回一个对象或者抛出异常 使用jdk的这种方式提 ...

  7. 什么是哈希Hash(散列函数)

    Hash(散列函数) Hash,一般翻译做散列.杂凑,或音译为哈希,是把任意长度的输入(又叫做预映射pre-image)通过散列算法变换成固定长度的输出,该输出就是散列值.这种转换是一种压缩映射,也就 ...

  8. JS事件 内容选中事件(onselect)选中事件,当文本框或者文本域中的文字被选中时,触发onselect事件,同时调用的程序就会被执行。

    内容选中事件(onselect) 选中事件,当文本框或者文本域中的文字被选中时,触发onselect事件,同时调用的程序就会被执行. 如下代码,当选中用户文本框内的文字时,触发onselect 事件, ...

  9. Python自学:第五章 对数字列表执行简单的统计计算

    >>>digits = [1,2,3,4,5,6,7,8,9,0] >>>mid(digits) 0 >>>max(digits) 9 >& ...

  10. Sqlite && EF Code FIRST 终极解决方案 2019.5.17

    Sqlite && EF Code FIRST 终极解决方案 2019.5.17 包括根据模型自动生成数据库,初始化数据,模型改变时的自动数据迁移等 2019.12.25 更新 支持E ...