题目链接:

Bomber Man wants to bomb an Array.

Time Limit: 4000/2000 MS (Java/Others)   

 Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 382    Accepted Submission(s): 114

Problem Description
Given an array and some positions where to plant the bombs, You have to print the Total Maximum Impact.

Each Bomb has some left destruction capability L and some right destruction capability R which means if a bomb is dropped at ith location it will destroy L blocks on the left and R blocks on the right.
Number of Blocks destroyed by a bomb is L+R+1
Total Impact is calculated as product of number of blocks destroyed by each bomb.
If ith bomb destroys Xi blocks then TotalImpact=X1∗X2∗....Xm

Given the bombing locations in the array, print the Maximum Total Impact such that every block of the array is destoryed exactly once(i.e it is effected by only one bomb).

### Rules of Bombing
1. Bomber Man wants to plant a bomb at every bombing location.
2. Bomber Man wants to destroy each block with only once.
3. Bomber Man wants to destroy every block.

 
Input
There are multi test cases denote by a integer T(T≤20) in the first line.

First line two Integers N and M which are the number of locations and number of bombing locations respectivly.
Second line contains M distinct integers specifying the Bombing Locations.

1 <= N <= 2000

1 <= M <= N

 
Output
as Maximum Total Impact can be very large print the floor(1000000 * log2(Maximum Total Impact)).

Hint:
Sample 1:

Sample 2:

 
Sample Input
2
10 2
0 9
10 3
0 4 8
 
Sample Output
4643856
5169925
 
题意:
 
xi为第i个炸弹炸的格子的数目,问x1*x2*..xm的最大值是多少;
 
 
思路:
 
比赛的时候直接没怎么想这题,后来看别人博客说是dp,然后发现是一个区间dp,在两个相邻格子的中间选取这两个炸弹的分界点,找到使ans最大的点;还有就是函数库里面没有log2的函数,可以用换底公式log2(n)=log10(n)/log(2);
 
 
AC代码:
 
/*
Problem : 5653 ( Bomber Man wants to bomb an Array. ) Judge Status : Accepted
RunId : 16703569 Language : G++ Author : 2014300227
*/
#include <bits/stdc++.h>
using namespace std;
int n,m,a[];
double dp[][];
const double N=;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i=;i<=m;i++)
for(int j=;j<=n;j++)
dp[i][j]=;
for(int i=;i<=m;i++)
{
scanf("%d",&a[i]);
a[i]++;
}
a[]=;
a[m+]=n+;
sort(a,a+m+);
for(int i=;i<a[];i++)
{
dp[][i]=log10(i*1.0)/log10(2.0)*N;
}
for(int i=;i<=m;i++)
{
for(int j=a[i];j<a[i+];j++)
{
for(int k=a[i-];k<a[i];k++)
{
dp[i][j]=max(dp[i][j],dp[i-][k]+log10((j-k)*1.0)/log10()*N);
}
}
}
int ans=(int)(dp[m][n]);
printf("%d\n",ans);
} return ;
}

hdu-5653 Bomber Man wants to bomb an Array.(区间dp)的更多相关文章

  1. HDU 5653 Bomber Man wants to bomb an Array. dp

    Bomber Man wants to bomb an Array. 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5653 Description ...

  2. hdu 5653 Bomber Man wants to bomb an Array

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5653 题意:已知炸弹可以炸掉左边L个位置,右边R个位置,那么炸点炸掉的总数是L+R+1.给定每个炸弹的 ...

  3. HDU5653 Bomber Man wants to bomb an Array 简单DP

    题意:bc 77 div1 1003(中文题面) 分析:先不考虑将结果乘以 1e6. 设 dp[i] 为从前 i 个格子的状态可以获得的最大破坏指数. 那么我们可以枚举每个炸弹,该炸弹向左延伸的距离和 ...

  4. [hdu contest 2019-07-29] Azshara's deep sea 计算几何 动态规划 区间dp 凸包 graham扫描法

    今天hdu的比赛的第一题,凸包+区间dp. 给出n个点m个圆,n<400,m<100,要求找出凸包然后给凸包上的点连线,连线的两个点不能(在凸包上)相邻,连线不能与圆相交或相切,连线不能相 ...

  5. HDU 4283 You Are the One (12年天津 区间DP)

    题意:有一个队列,每个人有一个愤怒值a[i],如果他是第k个上场,不开心指数就为(k-1)*a[i].但是边上有一个小黑屋(其实就是个堆栈),可以一定程度上调整上场程序 思路:枚举区间和每个人第几个上 ...

  6. HDU 4283---You Are the One(区间DP)

    题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4283 Problem Description The TV shows such as Y ...

  7. HDU 4293---Groups(区间DP)

    题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4293 Problem Description After the regional con ...

  8. hdu 4597 + uva 10891(一类区间dp)

    题目链接:http://vjudge.net/problem/viewProblem.action?id=19461 思路:一类经典的博弈类区间dp,我们令dp[l][r]表示玩家A从区间[l, r] ...

  9. HDU 1565&1569 方格取数系列(状压DP或者最大流)

    方格取数(2) Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total S ...

随机推荐

  1. display getSize()

    If you want the the display dimensions in pixels you can use getSize: Display display = getWindowMan ...

  2. C语言基础知识【环境设置】

    直接使用绿色版的VC++6.0就ok,后期我会写一个具体的使用教程

  3. Centos 安装libreoffice 生成office 报错信息见内容

    个人博客:https://blog.sharedata.info/ 错误信息:/opt/libreoffice5.2/program/soffice.bin: error while loading ...

  4. nginx访问日志中的时间格式修改

    1.说明 默认的时间格式是:[08/Mar/2013:09:30:58 +0800],由$time_local变量表示. 我想要改成如下格式:2013-03-08 12:21:03. 2.需要修改的文 ...

  5. Python过滤

    text = "A2A"s = filter(lambda ch: ch in '0123456789', text)print int(s)

  6. 9.Django里的数据同步migrations命令

    一个关键的目录: 目录名:migrations 作用:用来存放通过makemigrations命令生成的数据库脚本,这里的内容一般不要手动去改 规定:app目录下必须要有migrations目录且目录 ...

  7. hibernate 多对多 懒加载问题

    报错:org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net. ...

  8. tomcat调试页面的时候,不刷新

    1.调试一个页面的时候,js文件不刷新,也就是相当于没有改(cache) 2.解决:在Server中将当前tomcat的模式改为debug即可

  9. 设置某个字段为null

    update 表名 set 字段名=null WHERE 条件如下例子 update dwtz set ggid=null WHERE name_of_invested_company='浙江海翔药业 ...

  10. Java进阶学习:JSON解析利器JackSon

    Java:JSON解析利器JackSon JackSon基础 1.Maven项目引入 <!-- https://mvnrepository.com/artifact/org.codehaus.j ...