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

Problem Description
FSF is addicted to a stupid tower defense game. The goal of tower defense games is to try to stop enemies from crossing a map by building traps to slow them down and towers which shoot at them as they pass.



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.
Input
There are multiply test cases.



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)
Output
For each case, you should output "Case #C: " first, where C indicates the case number and counts from 1. Then output the answer. For each test only one line which have one integer, the answer to this question.
Sample Input
1
2 4 3 2 1
Sample Output
Case #1: 12
Hint
For 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.
Author
UESTC
Source
分析:红塔仅仅对过塔的人功击,绿塔对之后的全部塔的走过人功击,篮塔仅仅会廷长过塔时间,如果有n个塔,有e个绿塔。j个篮塔,k个红塔,n=e+j+k;红塔无论放哪里都仅仅对当前过塔人功击,要想总功击最大那么全部的红塔必须放在最后,那么如今仅仅要在枚举出e和j的个数,k=n-e-j; k个红塔都排在最后,设dp[i][j]表示前i个塔中有j个篮塔的最大功击值。
#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)的更多相关文章

  1. dp --- hdu 4939 : Stupid Tower Defense

    Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  2. hdu4939 Stupid Tower Defense (DP)

    2014多校7 第二水的题 4939 Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131 ...

  3. Stupid Tower Defense

    Problem Description FSF is addicted to a stupid tower defense game. The goal of tower defense games ...

  4. 初识Tower Defense Toolkit

    Tower Defense Toolkit 做塔防游戏的插件 主要层次如下图: 1GameControl _ _Game Control(Script) _ _ _Spawn Manager _ _ ...

  5. Tower Defense Game

    Tower Defense Game 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 There is a tower defense game with n level ...

  6. hdu 4779 Tower Defense (思维+组合数学)

    Tower Defense Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others) ...

  7. HDU 4779:Tower Defense

    Tower Defense Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)T ...

  8. HDU_4939 stupid tower defense 2014多校7 多变量型DP

    意思是有个塔防游戏,有三种塔,红塔在怪物经过的时候每秒会产生攻击力大小的伤害,绿塔对怪物经过以及经过之后每秒产生攻击力大小的伤害,还有种蓝塔,对怪物进行减速,即怪物从此之后经过一个单位都会减慢c秒 最 ...

  9. HDU 4939 Stupid Tower Defense(dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4939 解题报告:一条长度为n的线路,路上的每个单元格可以部署三种塔来给走在这条路上的敌人造成伤害,第一 ...

随机推荐

  1. (step8.2.2)hdu 2509(Be the Winner——简单博弈)

    题目大意:输入一个整数n,表示火柴堆数(原题其实指的是苹果堆数,但是为了尽量与模板保持一致,所以在这里理解为火柴堆数....其实理解为什么都没关系, 重要的是,理解就行....).在接下来的一行中,有 ...

  2. C++将文件内容一次性读入内存

    结合字符串流,将文件中的内容一次性读入内存,代码如下: #include <string> using std::ostringstream; using std::ifstream; u ...

  3. pomelo 协议

    分析的是hybridconnector,使用的chatofpomelo-websocket(pomelo为0.7.0) 參考:https://github.com/NetEase/pomelo/wik ...

  4. 17-UIKit(UIView的动画)

    2. UIView的动画 UIView类本身具有动画的功能 2.1 概念 由UI对底层Core Animation框架的封装 可以轻松简单的实现动画效果 2.2 两种使用方式 1> Block ...

  5. 13-UIKit(tableviewcell贴图、手势GestureRecognizer、transform变形)

    目录: 一.tableviewcell贴图 二.手势GestureRecognizer 5.1 Tap(按一下) 5.2 Swipe(轻扫一下) 5.3 pinch(捏/扩) 5.4 longPres ...

  6. SuperSocket源码解析之启动过程

    一 简介 这里主要说明从配置系统引导启动SuperScoekt作为应用程序,且以控制台程序方式启动 二 启动过程 2.1 配置解析 从读取配置文件开始,直接拿到一个SocketServiceConfi ...

  7. 解决QT Creator在Linux下的输入法问题

    https://vjudge1.github.io/2014/04/02/type-chinese-in-linux/http://blog.csdn.net/ubuntutouch/article/ ...

  8. ubuntu 12.04 安装sublime2

    add-apt-repository ppa:webupd8team/sublime-text-2 apt-get update apt-get install sublime-text 安装控制器: ...

  9. [置顶] 正则表达式应用:匹配email地址

           email的组成主要有三部分         1用户名部分 2@   3域名部分        1用户名部分         用户名一般有数值字母下划线组成,所以正则表达式为:[\da- ...

  10. linux下的软件包安装

    linux下安装软件包有两种方法:源文件编译安装(source)和 rpm 安装. 1.源文件包安装的通用方法. 一般安装源代码的程序你得要看它的README,一般在它的目录下都有的. 01.配置: ...