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
#include"iostream"
#include"cstdio"
#include"cstring"
using namespace std;
typedef __int64 LL;
const int ms=;
LL dp[ms][ms];
LL max(LL a,LL b)
{
return a>b?a:b;
}
int main()
{
LL ans,b,c;//注意 b和c 要定义为LL,因为后面的计算中含有LL形的数。
int T,p=;
int n,x,y,z,t;
scanf("%d",&T);
//cin>>T;
while(T--)
{
printf("Case #%d: ",p++);
//cout<<"Case #"<<p++<<": ";
scanf("%d%d%d%d%d",&n,&x,&y,&z,&t);
//cin>>n>>x>>y>>z>>t;
memset(dp,,sizeof(dp));
ans=x*n*t;
for(b=;b<=n;b++)
for(c=;c+b<=n;c++)
{
dp[b+][c]=max(dp[b+][c],dp[b][c]+c*y*(t+b*z));
dp[b][c+]=max(dp[b][c+],dp[b][c]+c*y*(t+b*z));
ans=max(ans,dp[b][c]+(n-b-c)*x*(t+b*z)+(n-b-c)*y*c*(t+b*z));
}
printf("%I64d\n",ans);
//cout<<ans<<endl;
}
return ;
}

Stupid Tower Defense的更多相关文章

  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. 初识Tower Defense Toolkit

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

  4. HDU4939Stupid Tower Defense (有思想的dp)

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

  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. hihoCoder #1199 : Tower Defense Game ——(树型dp)

    题目链接:https://hihocoder.com/problemset/problem/1199. 题意:一棵以1为根的树,每个点有一个p值和q值,到这个点需要当前分数大于等于p,然后消耗掉(p- ...

  9. HDU 4939 Stupid Tower Defense(dp)

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

随机推荐

  1. CSS基础(背景、文本、列表、表格、轮廓)

    CSS 背景属性 属性 描述 background 简写属性,作用是将背景属性设置在一个声明中. background-attachment 背景图像是否固定或者随着页面的其余部分滚动. backgr ...

  2. iOS完结篇

    从去年自己陆陆续续接触iOS开发,几个月过去了,对于苹果的体验,流程,以及规范都有了一定的认 识,还会定期关注iOS的发展. 即将要做win10系统了,为了纪念把自己的虚拟机截图留念吧.也希望微软能在 ...

  3. PID参数整定快速入门(调节器参数整定方法)

    PID调节器参数整定方法很多,常见的工程整定方法有临界比例度法.衰减曲线法和经验法.云润仪表以图文形式分别介绍调节器参数整定方法. 临界比例度法一个调节系统,在阶跃干扰作用下,出现既不发散也不衰减的等 ...

  4. eclipse中如何设置tomcat启动时间

    现象:在eclipse中启动tomcat总是提示“Server Tomcat v5.5 Server @ localhost was unable to start within 45 seconds ...

  5. linux下查看端口的占用情况

    前提:首先你必须知道,端口不是独立存在的,它是依附于进程的.某个进程开启,那么它对应的端口就开启了,进程关闭,则该端口也就关闭了.下次若某个进程再次开启,则相应的端口也再次开启.而不要纯粹的理解为关闭 ...

  6. Oracle-11g-R2 于 Linux 上的 RAC 卸载

    安装环境: SuSE Linux Enterprise Server 11 SP3 Oracle 11g 11.2.0.3   卸载步骤: 1.卸载 Database 软件(oracle,第一节点) ...

  7. C#多线程开发

    1.进程与线程的区别 通俗的讲,进行就是任务管理器中进行列表中看到的正在运行的程序,它是一个动态的概念,活动的实体. 线程是程序执行流的最小单元,是线程中一个实体,是系统独立调度和分派CPU基本单位. ...

  8. Ext.tree.Panel Extjs 在表格中添加树结构,并实现节点移动功能

    最近在用Extjs 做后台管理系统,真的非常好用.总结的东西分享一下. 先展示一下效果图 好了,开始吧! 首先说一下我的创建结构: 一.构造内容 这个函数中包括store的创建,treePanel的创 ...

  9. Debug with jdb

    原文地址: http://www.javaworld.com/article/2077445/testing-debugging/debug-with-jdb.html Q: How do you u ...

  10. IOS Note - Outlet(插座) & Action(动作)

    OutletActionViewController.h #import <UIKit/UIKit.h> @interface OutletActionViewController : U ...