一些題

Cheat

$$f_{i}$$表示當前匹配到第i個字符，最大能夠匹配的字符數。

$$O(len*loglen)$$

DZY Loves Math

$g(x)=\sum\limits_{i|x} f(i)\mu(\frac{x}{i})$

\begin{aligned} g(x)&=\sum\limits_{i|x}f(i)\mu(\frac{x}{i})\\ &=f(x)\sum\limits_{i|x且f(i)=f(x)}\mu(\frac{x}{i})+(f(x)-1)\sum\limits_{i|x且f(i)==f(x)-1}\mu(\frac{x}{i})\\ &=f(x)\sum\limits_{i|x}\mu(\frac{x}{i})-\sum\limits_{i|x且f(i)==f(x)-1}\mu(\frac{x}{i})\\ \end{aligned}

$$x=\prod p_i^{c_i}$$，將x的所有質因子分爲兩部分，一種是$$c_i=f(x)$$的，其他是另一種。

hdu6363 bookshelf

$$gcd(fib_x,fib_y)=fib_{gcd(x,y)}$$
$$gcd(x^i-1,x^j-1)=x^{gcd(i,j)}-1$$

DZY Loves Math IV

\begin{aligned} S(i,m)&=y*\sum\limits_{j=1}^{m}{\varphi(xj)}\\ &=y*\sum\limits_{j=1}^{m}\varphi(\frac {x}{gcd(x,j)})*\varphi(j)*gcd(x,j)\\ &=y*\sum\limits_{j=1}^{m}\varphi(\frac {x}{gcd(x,j)})*\varphi(j)*\sum\limits_{k|x且k|j}\varphi(k)\\ &=y*\sum\limits_{j=1}^{m}\varphi(j)\sum\limits_{k|x且k|j}\varphi(\frac {x}{k})\\ &=y*\sum\limits_{j|x}\varphi(\frac xj)\sum\limits_{k=1}^{\lfloor \frac mj \rfloor}\varphi(kj)\\ &=y*\sum\limits_{j|x}\varphi(\frac xj)S(j,\lfloor \frac mj \rfloor )\\ \end{aligned}