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. Tip提示框另类写法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. Some_problem_with_octopress

    今天我总算是使用上了高大上的octopress了,不容易啊,现在我把之前的博客全部搬到了octopress上了,在github上办博客让我不用再担心流量和广告了!---爽啊 我使用octopress时 ...

  3. 快速开发 jQuery 插件的 10 大技巧(转)

    转自:http://www.oschina.net/news/41776/jquery-10-tips 在开发过很多 jQuery 插件以后,我慢慢的摸索出了一套开发jQuery插件比较标准的结构和模 ...

  4. SRM DIV1 500pt DP

    SRM 501 DIV1 500pt SRM 502 DIV1 500pt SRM 508 DIV1 500pt SRM 509 DIV1 500pt SRM 511 DIV1 500pt SRM 5 ...

  5. HDU 1312 http://acm.hdu.edu.cn/showproblem.php?pid=1312

    #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #de ...

  6. AVCaptureDevice

    转载自:http://blog.csdn.net/andy_jiangbin/article/details/19820717   0.媒体采集的几个东西.这里所需要明白的是,在这个流程中,这里会存在 ...

  7. POJ 3177 Redundant Paths(强连通分量)

    题目链接:http://poj.org/problem?id=3177 题目大意是一个无向图给你n个点m条边,让你求出最少加多少条边 可以让任意两个点相通两条及以上的路线(每条路线点可以重复,但是每条 ...

  8. 12 为何使用Html5+CSS3

    一:大多浏览器支持,低版本也没问题 我看点这方面的资料,是为了做手机应用网站(有三个方案,这个是备用方案),可以开发响应式网站,可以脱离开发平台进行跨平台. 在Html5网页中引入Modernizr, ...

  9. Fibonacci数列

    问题描述 Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1. 当n比较大时,Fn也非常大,现在我们想知道,Fn除以10007的余数是多少. 输入格式 输入包含一个整数n ...

  10. Volley使用指南第三回(来自developer.android)

    继第二篇之后,再来Volley使用的教程的第三篇,有些翻译我是根据自己的理解,可能有错误的地方,还请多多包涵. 标准请求 这一回课将会告诉你Volley能够完成的3种请求类型 1.StringReqe ...