HDU4939Stupid Tower Defense (有思想的dp)
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
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.
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)
1
2 4 3 2 1
Case #1: 12HintFor 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.
#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)的更多相关文章
- dp --- hdu 4939 : Stupid Tower Defense
Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- hdu4939 Stupid Tower Defense (DP)
2014多校7 第二水的题 4939 Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131 ...
- Stupid Tower Defense
Problem Description FSF is addicted to a stupid tower defense game. The goal of tower defense games ...
- 初识Tower Defense Toolkit
Tower Defense Toolkit 做塔防游戏的插件 主要层次如下图: 1GameControl _ _Game Control(Script) _ _ _Spawn Manager _ _ ...
- Tower Defense Game
Tower Defense Game 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 There is a tower defense game with n level ...
- hdu 4779 Tower Defense (思维+组合数学)
Tower Defense Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others) ...
- HDU 4779:Tower Defense
Tower Defense Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others)T ...
- HDU_4939 stupid tower defense 2014多校7 多变量型DP
意思是有个塔防游戏,有三种塔,红塔在怪物经过的时候每秒会产生攻击力大小的伤害,绿塔对怪物经过以及经过之后每秒产生攻击力大小的伤害,还有种蓝塔,对怪物进行减速,即怪物从此之后经过一个单位都会减慢c秒 最 ...
- HDU 4939 Stupid Tower Defense(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4939 解题报告:一条长度为n的线路,路上的每个单元格可以部署三种塔来给走在这条路上的敌人造成伤害,第一 ...
随机推荐
- 放开chrome,微度新标签页 删除
来自VIc_:http://blog.csdn.net/Vic___ 本人只是提供方法建议,没有任何商业欲望. 欢迎转载 有一天,突然,我的标签栏,被改变了,这是怎么了,我的书签栏 我是一个镇定的人, ...
- android Bitmap围绕一个点进行旋转
在项目中需要使用定位功能,也就是一个点围绕一个圆心进行旋转,查看了canvas的函数也就只有一个 canvas.drawBitmap(bitmap, matrix, paint)通过使用Matrix来 ...
- JAVA操作Hbase基础例子
package com.cma.hbase.test; import java.io.BufferedInputStream; import java.io.BufferedReader; impor ...
- 我对国内两大购书站点的感受(dearbook和china-pub)
我在china-pub和dearbook都是老用户了(china-pub五星,dearbook钻石VIP).说一下近来我对两个站点的感觉. 1. Dearbook和当当合作以后送货速度比china-p ...
- 再造 “手机QQ” 侧滑菜单(三)——视图联动
代码示例:https://github.com/johnlui/SwiftSideslipLikeQQ 本 文中,我们将一起使用 UINavigationController 来管理主视图,并实现点击 ...
- 采用xml的方式保存数据
package com.example.myxmlmake; import java.io.File; import java.io.FileOutputStream; import java.uti ...
- Android开发--CardView使用
Android5.0中向我们介绍了一个全新的控件–CardView,从本质上看,可以将CardView看做是FrameLayout在自身之上添加了圆角和阴影效果.请注意:CardView被包装为一种布 ...
- 9天快速入门java
Java入门教程[9天快速入门JAVA] §1.3.简单的Java程序 下面我们先介绍两个简单的Java程序,并对其进行分析. 例1.1. public class HelloWorldApp{//a ...
- asp.net导出Excel类库
using System; using System.Collections.Generic; using System.Reflection; using System.Web; using Exc ...
- Java中的字符串驻留
转自:http://www.cdtarena.com/javapx/201307/9088.html 最近在工作的时候,一句再正常不过的代码String a = “hello” + “world”;被 ...