hdu 5653 Bomber Man wants to bomb an Array
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5653
题意:已知炸弹可以炸掉左边L个位置,右边R个位置,那么炸点炸掉的总数是L+R+1。给定每个炸弹的位置,求所有炸弹炸掉的格数总乘积
输出floor(1e6*log2(总乘积))那么到计算时就变成先取对数相加,最后乘以1e6下取整
思路:dp[r]=dp[l-1]*log2(r-l+1)当前区间的最大值等于上一个区间的最大值加上当前的值,解释见代码
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<vector>
#include<queue>
#include<map>
#include<iterator>
#include<vector>
#include<set>
#define INF 9999999
typedef long long ll;
const int Max=(<<)+;
using namespace std; double dp[];
int num,n,m,b[]; int main()
{
scanf("%d",&num);
while(num--)
{
scanf("%d %d",&n,&m);
for(int i=;i<=m;i++)
{
scanf("%d",&b[i]);
b[i]++;
} sort(b+,b+m+); b[m+]=n+;
memset(dp,,sizeof(dp)); for(int i=;i<=m;i++)
{
for(int j=b[i-]+;j<=b[i];j++)
{
for(int k=b[i];k<=b[i+]-;k++)
dp[k]=max(dp[k],dp[j-]+log2(k-j+1.0));//枚举区间求最大值,j表示当前区间的起点,k表示当前区间的终点,j-1表示上一个区间
}
}
ll ans=floor(1e6*dp[n]);
printf("%lld\n",ans);
}
return ;
}
hdu 5653 Bomber Man wants to bomb an Array的更多相关文章
- 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 ...
- hdu-5653 Bomber Man wants to bomb an Array.(区间dp)
题目链接: Bomber Man wants to bomb an Array. Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65 ...
- HDU5653 Bomber Man wants to bomb an Array 简单DP
题意:bc 77 div1 1003(中文题面) 分析:先不考虑将结果乘以 1e6. 设 dp[i] 为从前 i 个格子的状态可以获得的最大破坏指数. 那么我们可以枚举每个炸弹,该炸弹向左延伸的距离和 ...
- BestCoder Round #77
T1 xiaoxin juju needs help 计算组合数然后多重集排列乱搞,注意判无解情况(TM我就判错然后FST了). #include<cstdio> #include< ...
- HDU 5164Matching on Array(AC自动机)
这是BC上的一道题,当时比赛没有做,回头看看题解,说是AC自动机,想着没有写过AC自动机,于是便试着抄抄白书的模板,硬是搞了我数个小时2000ms时限1800过了= = ! 这里就直接贴上BC的结题报 ...
- hdu 5635 LCP Array(BC第一题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5635 LCP Array Time Limit: 4000/2000 MS (Java/Others) ...
- 2017 多校2 hdu 6053 TrickGCD
2017 多校2 hdu 6053 TrickGCD 题目: You are given an array \(A\) , and Zhu wants to know there are how ma ...
- hud 3336 count the string (KMP)
这道题本来想对了,可是因为hdu对pascal语言的限制是我认为自己想错了,结果一看题解发现自己对了…… 题意:给以字符串 计算出以前i个字符为前缀的字符中 在主串中出现的次数和 如: num(aba ...
- HDU 5934 Bomb(炸弹)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
随机推荐
- Linux学习:用yum安装php,httpd,mysql
见鸟哥的linux私房菜电子版832页.
- jquery获取和设置表单数据
1.需求 正好做到设置和获取表单数据的功能,做个整理 2.计划安排 3.计划实施 1.获取值 <!--1获取普通文本框的值--> <input type="text&quo ...
- Oracle 多表查询优化
ORACLE有个高速缓冲的概念,这个高速缓冲就是存放执行过的SQL语句,那oracle在执行sql语句的时候要做很多工作,例如解析sql语句,估算索引利用率,绑定变量,读取数据块等等这些操作.假设高速 ...
- [转]ubuntu 14.04 如何开启和关闭触控板
转自:http://lxn348567248.blog.163.com/blog/static/1201759252014649443513/ 禁用触摸板的命令: sudo rmmod psmous ...
- python 端口扫描仪
思路:使用socket进行连接测试,即客户端连接服务器. 核心代码如下: from socket import * def try_port(ip,port,protocol = SOCK_STREA ...
- 【Eclipse】在Eclipse工具中自定义类注释
直接上图:这个公司基本都已经定制好了,自己写demo的时候可以适当定制自己的注释 package com.zlg.controller; zlg : 此处输入zlg(对应模版的名称) 然后ALT+/ ...
- faac编码aac
// faacode.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <faac.h> #include &l ...
- linux系统vsftpd登陆慢卡怎么办
linux系统vsftpd登陆慢卡怎么办 浏览:145 | 更新:2013-12-31 00:50 vsftpd是linux系统中的一款ftp软件,用它可以实现文件,数据上传与下载,但有些用户会发现v ...
- iOS_隐藏顶部状态栏方式
关键词:IOS.UIViewController. Status Bar iOS6和iOS7在隐藏 Status Bar 三种方式比较: Storyboard 界面上选中UIViewControlle ...
- 【smarty项目源码】模拟smarty模版文件的解析过程
<?php class MyMiniSmarty{ //模版文件的存放路径 var $template_dir="./templates/"; //编译文件的存放路径 ,编译 ...