0%

P1412 经营与开发

思路讲解

1
2
3
4
5
6
7
8
9
10
11
// 以i为起点,初始值为w,所能够获得的最大收益
vdb dp(N+5);
ROF(i,N,1){
auto [type,val]=A[i];
if(type==1){
dp[i]=max(dp[i+1],dp[i+1]*(1-cost*0.01)+val*W);
}else{
dp[i]=max(dp[i+1],dp[i+1]*(1+grow*0.01)-val*W);
}
}
cout<<fsp(2)<<dp[1]<<"\n";

这道题目,我认为关键点在这里,因此我们推一下

W×val+W×(10.01×cost)×val2+W×(10.01×cost)2×val3W\times val+W\times (1-0.01\times cost)\times val_2 +W\times (1-0.01\times cost)^2\times val_3

不难发现,无论怎么样操作,一个星球的收益一定是一个连乘的式子,因此上述操作就不难理解了。

AC代码

https://vjudge.net/solution/62959677

心路历程(WA,TLE,MLE……)