# 2023.4-2023.5 水題記錄 (持續更新)

## 2. P5104 紅包發紅包

$f(x)=\begin{cases}\dfrac{1}{w},&x\in[0,w]\\0,&\text{otherwise}\end{cases}$

$E_1(w)=\int_{-\infty}^{+\infty}xf(x)\mathrm{d}x=\int_{0}^{w}xf(x)\mathrm{d}x=\dfrac{w}{2}$

$E_k(w)=\int_{0}^{w}E_{k-1}(w-x)f(x)\mathrm{d}x$

## 3. CF1333E Road to 1600

$\begin{matrix} 2 & 8 & 7\\ 3 & 4 & 6\\ 1 & 5 & 9 \end{matrix}$

## 6. CF938E Max History

$\sum\limits_{i=0}^{k_p}\dbinom{k_p}{i}i!(n-i-1)!$

## 7. P5752 [NOI1999] 棋盤分割

(具體狀態轉移如下)

inline int s(int xa,int ya,int xb,int yb)
{
return sum[xb][yb]-sum[xb][ya-1]-sum[xa-1][yb]+sum[xa-1][ya-1];
}
inline int sq(int xa,int ya,int xb,int yb)
{
return s(xa,ya,xb,yb)*s(xa,ya,xb,yb);
}
inline int maxc(int xa,int ya,int xb,int yb){return xb-xa+yb-ya;}
int dfs(int xa,int ya,int xb,int yb,int c)
{
if(f[xa][ya][xb][yb][c]!=inf)return f[xa][ya][xb][yb][c];
if(c==0)return f[xa][ya][xb][yb][c]=sq(xa,ya,xb,yb);
for(int xx=xa;xx<=xb-1;xx++)
{
if(maxc(xa,ya,xx,yb)>=c-1)
f[xa][ya][xb][yb][c]=min(f[xa][ya][xb][yb][c],sq(xx+1,ya,xb,yb)+dfs(xa,ya,xx,yb,c-1));
if(maxc(xx+1,ya,xb,yb)>=c-1)
f[xa][ya][xb][yb][c]=min(f[xa][ya][xb][yb][c],sq(xa,ya,xx,yb)+dfs(xx+1,ya,xb,yb,c-1));
}
for(int yy=ya;yy<=yb-1;yy++)
{
if(maxc(xa,ya,xb,yy)>=c-1)
f[xa][ya][xb][yb][c]=min(f[xa][ya][xb][yb][c],sq(xa,yy+1,xb,yb)+dfs(xa,ya,xb,yy,c-1));
if(maxc(xa,yy+1,xb,yb)>=c-1)
f[xa][ya][xb][yb][c]=min(f[xa][ya][xb][yb][c],sq(xa,ya,xb,yy)+dfs(xa,yy+1,xb,yb,c-1));
}
return f[xa][ya][xb][yb][c];
}


## 9. P2048 [NOI2010] 超級鋼琴

$\max\{s_i\}-s_{x+l},i\in[x+l-1,\min\{n,x+r-1\}]$

## 13. [ARC127C] Binary Strings

• 若排名的最高位 (帶前導零) 是 $$0$$, 則下一位是 $$0$$, 去掉最高位並減 $$1$$.
• 否則下一位是 $$1$$, 去掉最高位, 無需減 $$1$$.
• 如果某次減 $$1$$ 後變成了 $$0$$, 那麼立即結束.

(好像還是很抽象)

## 16. CF1325D Ehab the Xorcist

$$d=u-v$$. 然後會神奇地發現 $$(\dfrac{d}{2},\dfrac{d}{2},v)$$ 就滿足要求.

(咕咕咕)