I. Misunderstood … Missing 倒序dp

I题
题意:一共有n轮,你每次可以选择三种操作,第一种就是攻击怪兽,造成伤害A+ai,第二种就是提高自己的属性,以后每轮攻击力都增加bi,第三种提高攻击力,攻击力增加ci,问你最多能造成的伤害是多少。
题解:这题我一看n,想暴力,发现不行,因为你不能确定那几轮操作干嘛,所以只能dp,dp也不是那么容易,首先这题要倒序dp,倒序dp有什么好处呢,就是如果一个题不要考虑前效应就能用,设dp[i][j][k],代表第i轮到第n轮,攻击了j次,攻击j次的轮数下标之和(为啥要d这个呢,因为我对于第二种操作我不是那么容易算贡献,那么第二种操作的贡献,如果我攻击几次的轮数都知道,那么对于该次操作它的贡献为 b[i]*(x1-i+x2-i+…xj-i),那么你会发现我们并不用求具体攻击在那几轮,只需要知道j次攻击下标之和就能算出第二次操作的贡献)。
那么dp怎么转移呢?
dp[i+1][j][k+j] = max(dp[i][j][k] + max(j * c[i], b[i] * (k+j)),dp[i+1][j][k+j]);
//这是执行二三操作
dp[i+1][j+1][j+k] = max(dp[i+1][j+1][j+k],dp[i][j][k]+a[i]);
//这是执行操作一
然后为什么要到下轮就是k+j了,因为我们是倒着dp的,所以相当于起点往后移了,那么j次攻击的下标是不是都+1了,那么j次就+j。
(这题我学了巨久,代码借鉴橘子猫学长的)

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[110],b[110],c[110];
ll dp[2][110][5060];
void clear(int cul)
{
    for(int i=0;i<110;i++) for(int j=0;j<5060;j++) dp[cul][i][j] = -1;
}
int main()
{
    int t;scanf("%d",&t);
    while(t--)
    {
        ll ans = 0 ;
        int cul = 0;
        int n;scanf("%d",&n);
        for(int i=n;i>=1;i--) scanf("%d%d%d",&a[i],&b[i],&c[i]);
        clear(cul);dp[0][0][0] = 0;
         for(int i=1;i<=n;i++)
         {
             cul = !cul;
             clear(cul);
             for(int j=0;j<i;j++)
                for(int k=0;k<=i*(i-1)/2;k++)
             {
                 if(dp[!cul][j][k]==-1) continue;
                 dp[cul][j+1][k+j] = max(dp[cul][j+1][k+j],dp[!cul][j][k]+a[i]);
                 ans = max(dp[cul][j+1][k+j],ans);
                 dp[cul][j][k+j] = max(dp[!cul][j][k]+max(1LL*j*c[i],1LL*b[i]*(k+j)),dp[cul][j][k+j]);
                 ans = max(dp[cul][j][k+j],ans);
             }
         }
         printf("%lld\n",ans);
    }
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
and debugged. Its widespread availability allows PCB professionals to exchange image drill and route securely and efficiently. The RS-274X format is simple, compact and unequivocal. It is easy to interpret. It describes an image with very high precision. It is complete: one single file describes an image. It is portable and easy to debug by its use of printable 7-bit ASCII characters. A well-constructed RS-274X file precisely defines the PCB image data and the functions of the different image elements. Unfortunately, poorly constructed or simply erroneous RS-274X files also circulate, sometimes leading to unjustified criticism of the format itself. Errors may be due to a misunderstanding of the format. With more than 25 years experience in CAM software we at Ucamco know which areas are most often misunderstood. This revision of the RS-274X specification explains these areas more clearly. Other files are not invalid but poorly constructed. Especially troublesome are painted or stroked pads and copper planes. Poorly constructed files take longer to process, require more manual work and increase the risk of errors. This revision of the RS-274X specification recommends constructions to make RS-274X files safer and more efficient, and hence fabrication more reliable, faster and cheaper. A few words must be said about RS-274-D or Standard Gerber. This format was developed to drive NC machine tools and was used for Gerber vector plotters in the 1960s and 1970s. It is not an image description format. It is amazing that it is still used. It is like using teletype paper tape to transfer text documents. We call on industry experts and professional organizations to discourage the use of the obsolete RS-274-D format. Although other data transfer formats have come into the market, they have not displaced RS-274X. The reason is simple. More than 90% of the problems in data transfer are due not to limitations in the RS-274X format but to poor practices and, worse, the use of RS-274

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值