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. Maven创建项目: Failed to execute goal org.apache.maven.plugin( mvn archetype:create)

    一.概述: 在使用mvn 命令mvn archetype:create -DgroupId=com.chuanliu.c11 -DartifactId=c11searcher在控制创建maven项目和 ...

  2. c++參数传递

    定义: 形參:指出如今Sub 和Function过程形參表中的变量名.数组名,该过程在被调用前.没有为它们分配内存.其作用是说明自变量的类型和形态以及在过程中的作用.形參能够是除定长字符串变量之外的合 ...

  3. Android 系统稳定性 - ANR(一)

    文章都为原创,转载请注明出处,未经允许而盗用者追究法律责任.很久之前写的了,留着有点浪费,共享之.编写者:李文栋  如果你是一个Android应用程序开发人员,你的人生中不可避免的三件事情是:死亡.缴 ...

  4. C# 点击窗口任意位置拖动

    代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...

  5. BZOJ 2318: Spoj4060 game with probability Problem( 概率dp )

    概率dp... http://blog.csdn.net/Vmurder/article/details/46467899 ( from : [辗转山河弋流歌 by 空灰冰魂] ) 这个讲得很好 , ...

  6. Python 第八篇:异常处理、Socket语法、SocketServer实现多并发、进程和线程、线程锁、GIL、Event、信号量、进程间通讯

    本节内容: 异常处理.Socket语法.SocketServer实现多并发.进程和线程.线程锁.GIL.Event.信号量.进程间通讯.生产者消费者模型.队列Queue.multiprocess实例 ...

  7. tab group of firefox

    https://addons.mozilla.org/en-US/firefox/addon/tabgroups-menu/? src=search#detail-relnotes https://g ...

  8. opencv视频播放

    在一个界面上显示一张图片.是一件非常easy的事情,但说到要显示视频.刚開始学习的人可能不知道怎么处理,事实上,一般来说能够理解为视频就是图片以人眼察觉不到的速度高速更新. 曾经用摄像头採集视频显示在 ...

  9. Windows NT 技术简介

    Windows NT 技术简介 NT:New Technoly(新技术,因比DOS.WIN9X采用了很多新技术而得名) Windows NT基本介绍 WindowsNT是Microsoft推出的面向工 ...

  10. linux 下vi中关于删除某段,某行,或者全部删除的命令

    1,先打开某个文件: vi   filename 2,转到文件结尾 在命令模式输入 G       转到10行 在命令模式输入 10G 4,删除所有内容:先用G 转到文件尾,然后使用下面命令: :1, ...