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. lighttpd为什么要accept多次呢

    在lighttpd网络模型里面我们可以看到以下代码 /* accept()s at most 100 connections directly * * we jump out after 100 to ...

  2. Result consisted of more than one row 错误的解决

    创建MySql的存储过程时,发生“Result consisted of more than one row”的错误. 存储过程的代码如下: )) BEGIN SELECT PetName into ...

  3. Tkinter教程之Button篇(2)

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811300 # Tkinter教程之Button篇(2)'''5.指定Button的宽度与高度 ...

  4. HDU5742:It's All In The Mind(模拟+贪心 )

    题意: 给出n和m,表示n个数,之后会给出m个下标xi和值yi,a[xi]=yi,n个数是不下降的,且总和>0,要使得(x1+x2)/∑(xi)最大. 分析: 尽可能使得前两个数最大,其他数尽可 ...

  5. 【移动开发】安卓Lab2(02)

    Design UI 总共有三个activity 1. MainActitivty: search bar:先用edittext来代替 map:用imageview装图片 2. DetailActiti ...

  6. Spring入门(9)-AOP初探

    Spring入门(9)-AOP初探 0. 目录 什么是面向切面编程 AOP常见术语 AOP实例 参考资料 1. 什么是面向切面编程 Aspect Oriented Programming(AOP),即 ...

  7. poj 1847 Tram

    http://poj.org/problem?id=1847 这道题题意不太容易理解,n个车站,起点a,终点b:问从起点到终点需要转换开关的最少次数 开始的那个点不需要转换开关 数据: 3 2 1// ...

  8. Objective-c setObject:forKey:和setValue:forKey:的区别

    setObject:forKey: 是NSMutableDictionary类的方法                               key参数类型可以是任意类型对象           ...

  9. Jstl标签的使用

    一. 配置 JSTL 包括两个 JAR 文件, jstl.jar 和 standard.jar .是什么没有必要管,重在应用( 1+1 ? =2 ,我们没有必要深究,只需要知道这么用就行.). 原文引 ...

  10. 在VS中安装EF和项目引用EF

    1.通过Visual Studio安装NuGet (1). 打开Visual Studio扩展管理器     (2). 选择联机库,并在搜索中写入NuGet,然后点击搜索结果中NuGet Packag ...