题目链接:

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. 多媒体开发之---h264格式slice_header

    从Slice_Header学习H.264 写在前面: $     H.264我是结合标准和毕厚杰的书一块学的.看句法语义时最是头疼,一大堆的元素,很需要耐心.标准中在介绍某个元素的语义时,经常会突然冒 ...

  2. Photoshop经常使用快捷键(2)

    51.自由变换外框右键属性:ESC 取消 斜切:能够依照该调节边角点所引导出的两条边的角度进行移动.ctrl+shift 扭曲:随意点的调节.  ctrl 透视:模拟近大远小的关系.ctrl+shif ...

  3. Android Material Design-Defining Shadows and Clipping Views(定义阴影和裁剪视图)-(四)

    转载请注明出处:http://blog.csdn.net/bbld_/article/details/40539131 翻译自:http://developer.android.com/trainin ...

  4. 用android studio创建第一个安卓程序加载html5 页面

    前言 软件版本:android studio v1.0正式版,由于v0.x以来软件变化一直比较大,很多问题搜索的解决方案也都是v0.x版本时代的,故首先声明一下版本. 动机:由于工作中需要对移动端软件 ...

  5. Unity框架入门

    介绍Unity框架之前,先要说几个概念DIP依赖倒置原则.IOC控制反转.DI依赖注入 DIP是设计原则之一,定义:上层不应该依赖于底层,两者都依赖于抽象: 抽象不依赖于细节,细节应该依赖于抽象. 像 ...

  6. 图解堆算法、链表、栈与队列(Mark)

    原文地址: 图解堆算法.链表.栈与队列(多图预警) 堆(heap),是一类特殊的数据结构的统称.它通常被看作一棵树的数组对象.在队列中,调度程序反复提取队列中的第一个作业并运行,因为实际情况中某些时间 ...

  7. Wooden Sticks(hdu1051)

    Wooden Sticks Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  8. dubbo开发中使用到的一些服务配置方式

    通过之前的学习了解了dubbo的常规的使用,下面我们看看特殊情况或者说真实环境下使用dubbo的一些配置实例. 一.一个接口有多个实现时可以使用group来区分 1.服务提供者配置 <?xml  ...

  9. WCF基础之会话、实例和并发

    这篇笔记是一些概念性的东西. 会话,借用百科上的描述就是一个客户与服务器之间的不中断的请求响应序列.wcf的会话模式是通过服务契约的SessionModel进行设置的,其值为枚举,分别为:Allowe ...

  10. 九度OJ 1354:和为S的连续正数序列 (整除)

    时间限制:2 秒 内存限制:32 兆 特殊判题:否 提交:2028 解决:630 题目描述: 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100.但是他并不 ...