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. Qt 富文本处理(QTextDocument和QTextBlock和QTextFrame和QTextTable和QTextList和QTextDocument)

    最近使用 Qt 做一个离线博客编辑器,因而用到了 Qt 的富文本处理.参考 Qt 的文档,记录下 Qt 的富文本处理的相关技术.文档地址是 http://doc.qt.nokia.com/4.7/ri ...

  2. CVPapers论文整理工具-开源

    一.工具介绍及运行实例 相信计算机视觉领域的同道中人都知道这个Computer Vision Resource网站, http://www.cvpapers.com/  网页部分截图如下: 可以看到有 ...

  3. 基于visual Studio2013解决C语言竞赛题之0707月份输出

     题目 解决代码及点评 /* 编一程序,打入月份号,输出该月的英文月名. 例如,输入"3",则输出"March",要求用指针数组处理. */ #includ ...

  4. OGR – Merging Multiple SHP files

    So I have 25 shapefiles with data for 25 counties, and I want to merge them all into one shapefile. ...

  5. [转]Cocos Studio和Cocos2d-x版本对应关系

    2015-1-19阅读139 评论0 From: http://www.cocoachina.com/bbs/read.php?tid=182077 版本对应列表: Studio2.x CocosSt ...

  6. wcf 出现 IsContentTypeSupported 错误

    查看添加的服务地址是不是https开头的,而 *.config 文件里面自动添加的链接变成了http,当前的bindbing类型为basicHttpBinding, 解决方法:在config文件里面手 ...

  7. Ch04 充满动作的控制器

    4.1  考察控制器和动作 4.1.1  IController与控制器基类 4.1.2  如何形成动作方法 4.2  哪些应该放在动作方法中 4.2.1  手动映射视图模型 4.2.2  输入验证 ...

  8. Ch03 视图基础

    3.1  视图简介 3.1.1  选择待渲染视图 3.1.2  重写视图名 3.2  给视图传递数据 3.2.1  ViewDataDictionary 3.2.2  ViewBag 3.2.3  带 ...

  9. 设置HTTP代理

    Maven通过<<UserHome>>/.m2/settings.xml(如果没有该文件,复制<<MavenHome>>/conf/settings.x ...

  10. boost之program_options库,解析命令行参数、读取配置文件

    一.命令行解析 tprogram_options解析命令行参数示例代码: #include <iostream> using namespace std; #include <boo ...