j带来的贡献:
\(f[i]*b^{j-i}+\sum(i\cdot\text{num}[i+1..j])+pre_{j-i}\)
\(\displaystyle\sum_{j=i+1}^n\left\{f[i]*b^{j-i}+i\cdot\dfrac{b^{j-i}(b^{j-i}-1)}2+pre_{j-i}\right\}\)
\(\displaystyle\sum_{j=1}^{n-i}\left\{f[i]*b^j+i\cdot\dfrac{b^j(b^j-1)}2+pre_j\right\}\)
\(\displaystyle f[i]*\sum_{j=1}^{n-i}b^j+i\cdot\sum_{j=1}^{n-i}\dfrac{b^j(b^j-1)}2+pre_j\)
预处理:\(\displaystyle spw[i]=\sum_{j\in[1..i]}b^j,apw[i]=\sum_{j\in[1..i]}\dfrac{b^j(b^j-1)}2,sum[i]=\sum_{j\in[1..i]}pre_j\)
\(\displaystyle\sum_{b_i\in[0,a_i-1]}\Big(f[i]*spw[n-i]+i*apw[n-i]+sum[n-i]\Big)\)
\(f[i]=f[i-1]+i*b_i\)
\(\displaystyle\sum_{b_i\in[0,a_i-1]}\Big((f[i-1]+i*b_i)*spw[n-i]+i*apw[n-i]+sum[n-i]\Big)\)
\(a_i*i*apw[n-i]+a_i*sum[n-i]+spw[n-i]*a_i*f[i-1]+i*spw[n-i]*\dfrac{a_i(a_i-1)}2\)
\(f[i]=f[i-1]*b+i*a[i]\)
\(i\)本身的贡献:\(\displaystyle\sum_{b_i\in[0,a_i]}\left\{f[i-1]*b+i*b_i\right\}\)
\((a[i]+1)*f[i-1]*b+i*\dfrac{a_i(a_i+1)}2\)
算完了。
标签:pre,数数,..,dfrac,sum,P3281,题解,spw,displaystyle From: https://www.cnblogs.com/laijinyi/p/18148381