HDU4939Stupid Tower Defense (有思想的dp)
Stupid Tower Defense
Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1557 Accepted Submission(s): 445
The map is a line, which has n unit length. We can build only one tower on each unit length. The enemy takes t seconds on each unit length. And there are 3 kinds of tower in this game: The red tower, the green tower and the blue tower.
The red tower damage on the enemy x points per second when he passes through the tower.
The green tower damage on the enemy y points per second after he passes through the tower.
The blue tower let the enemy go slower than before (that is, the enemy takes more z second to pass an unit length, also, after he passes through the tower.)
Of course, if you are already pass through m green towers, you should have got m*y damage per second. The same, if you are already pass through k blue towers, the enemy should have took t + k*z seconds every unit length.
FSF now wants to know the maximum damage the enemy can get.
The first line contains an integer T (T<=100), indicates the number of cases.
Each test only contain 5 integers n, x, y, z, t (2<=n<=1500,0<=x, y, z<=60000,1<=t<=3)
1
2 4 3 2 1
Case #1: 12HintFor the first sample, the first tower is blue tower, and the second is red tower. So, the total damage is 4*(1+2)=12 damage points.
#include<stdio.h>
#include<string.h>
#define ll __int64
ll dp[1505][1505];
int main()
{
ll T,n,x,y,z,t,ans,c=0,aa;
for(int i=0;i<=1500;i++)
dp[0][i]=0;
scanf("%I64d",&T);
while(T--)
{
scanf("%I64d%I64d%I64d%I64d%I64d",&n,&x,&y,&z,&t);
ans=n*t*x;
for(ll i=1;i<=n;i++)
for(ll j=0;j<=i;j++)
{
dp[i][j]=dp[i-1][j]+(i-1-j)*(j*z+t)*y;//第i个塔是绿塔
if(j>0)
{
aa=dp[i-1][j-1]+(i-j)*((j-1)*z+t)*y;//第i个塔是篮塔
if(dp[i][j]<aa) dp[i][j]=aa;
}
aa=dp[i][j]+((i-j)*y+x)*(j*z+t)*(n-i);//加上红塔的功击值(来自前面的塔和自身)
if(aa>ans) ans=aa;
} printf("Case #%I64d: %I64d\n",++c,ans);
}
}
HDU4939Stupid Tower Defense (有思想的dp)的更多相关文章
- dp --- hdu 4939 : Stupid Tower Defense
Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- hdu4939 Stupid Tower Defense (DP)
2014多校7 第二水的题 4939 Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131 ...
- Stupid Tower Defense
Problem Description FSF is addicted to a stupid tower defense game. The goal of tower defense games ...
- 初识Tower Defense Toolkit
Tower Defense Toolkit 做塔防游戏的插件 主要层次如下图: 1GameControl _ _Game Control(Script) _ _ _Spawn Manager _ _ ...
- Tower Defense Game
Tower Defense Game 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 There is a tower defense game with n level ...
- hdu 4779 Tower Defense (思维+组合数学)
Tower Defense Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others) ...
- HDU 4779:Tower Defense
Tower Defense Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others)T ...
- HDU_4939 stupid tower defense 2014多校7 多变量型DP
意思是有个塔防游戏,有三种塔,红塔在怪物经过的时候每秒会产生攻击力大小的伤害,绿塔对怪物经过以及经过之后每秒产生攻击力大小的伤害,还有种蓝塔,对怪物进行减速,即怪物从此之后经过一个单位都会减慢c秒 最 ...
- HDU 4939 Stupid Tower Defense(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4939 解题报告:一条长度为n的线路,路上的每个单元格可以部署三种塔来给走在这条路上的敌人造成伤害,第一 ...
随机推荐
- 利用SolrJ操作solr API完成index操作
使用SolrJ操作Solr会比利用httpClient来操作Solr要简单.SolrJ是封装了httpClient方法,来操作solr的API的.SolrJ底层还是通过使用httpClient中的方法 ...
- 基于visual Studio2013解决C语言竞赛题之0510求最大和
题目
- JAVA操作Hbase基础例子
package com.cma.hbase.test; import java.io.BufferedInputStream; import java.io.BufferedReader; impor ...
- c语言统计字符数(判断a-z哪个字符出现次数最多)
http://poj.grids.cn/practice/2742 描述判断一个由a-z这26个字符组成的字符串中哪个字符出现的次数最多输入第1行是测试数据的组数n,每组测试数据占1行,是一个由a-z ...
- 运行复制的ZooKeeper 部署
运行复制的ZooKeeper 运行ZooKeeper 在一个独立模式下是方便评估的, 一些开发,和测试. 但是在生产,你应该运行ZooKeeper 在复制模式.一个复制的servers group 在 ...
- httplib,urllib和urllib2
一.httplib实现了HTTP和HTTPS的客户端协议,一般不直接使用,在python更高层的封装模块中(urllib,urllib2)使用了它的http实现. import httplib con ...
- 道格拉斯—普克(Douglas一Peukcer)节点抽稀算法
Douglas一Peukcer算法由D.Douglas和T.Peueker于1973年提出,简称D一P算法,是眼下公认的线状要素化简经典算法.现有的线化简算法中,有相当一部分都是在该算法基础上进行改进 ...
- 我的Android进阶之旅------>HTTP 返回状态值详解
(本文转载于:http://blog.csdn.net/ithomer/article/details/10240351) 当用户点击或搜索引擎向网站服务器发出浏览请求时,服务器将返回Http Hea ...
- Bernstein polynomials
Bernstein多项式能够用来一致逼近闭区间上的连续函数. 对于[0,1]上的连续函数f(x),定义Bernstein多项式 B_n(f,x) = sum{k=0..n} f(k/n)C(k,n)t ...
- 使用linq对字符串1,2,3,4,5,6,7,8,9,10求和
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SumI ...