A {\displaystyle \mathbf {A} } 是长度为 N {\displaystyle N} 的序列。求 ∑ i = 1 R ( N R − i ∑ p ∈ { 0 , 1 , ⋯ , N − 1 } i ∏ j ≠ p 0 ( A j − ∑ k = 1 i − 1 [ p k = j ] ) ) mod 10 9 + 7 {\displaystyle \sum _{i=1}^{R}{\left(N^{R-i}\sum _{\mathbf {p} \in \{0,1,\cdots ,N-1\}^{i}}{\prod _{j\neq \mathbf {p} _{0}}{\left(\mathbf {A} _{j}-\sum _{k=1}^{i-1}{[\mathbf {p} _{k}=j]}\right)}}\right)}\mod 10^{9}+7} 。 N ≤ 2000 , R ≤ 10 9 {\displaystyle N\leq 2000,R\leq 10^{9}}
sin ( α ± β ) = sin α cos β ± cos α sin β cos ( α ± β ) = cos α cos β ∓ sin α sin β tan ( α ± β ) = tan α ± tan β 1 ∓ tan α tan β sin 2 θ = 2 sin θ cos θ = 2 tan θ 1 + tan 2 θ cos 2 θ = cos 2 θ − sin 2 θ = 1 − tan 2 θ 1 + tan 2 θ sin 3 θ = 3 sin θ − 4 sin 3 θ cos 3 θ = 4 cos 3 θ − 3 cos θ sin ( α + β ) sin ( α − β ) = sin 2 α − sin 2 β cos ( α + β ) cos ( α − β ) = cos 2 α − sin 2 β sin 2 θ = 1 − cos 2 θ 2 cos 2 θ = 1 + cos 2 θ 2 sin α sin β = − cos ( α + β ) − cos ( α − β ) 2 sin α cos β = sin ( α + β ) + sin ( α − β ) 2 cos α cos β = cos ( α + β ) + cos ( α − β ) 2 sin α + sin β = 2 sin α + β 2 cos α − β 2 sin α − sin β = 2 cos α + β 2 sin α − β 2 cos α + cos β = 2 cos α + β 2 cos α − β 2 cos α − cos β = − 2 sin α + β 2 sin α − β 2 sin θ 2 = ± 1 − cos θ 2 cos θ 2 = ± 1 + cos θ 2 tan θ 2 = ± 1 − cos θ 1 + cos θ = sin θ 1 + cos θ = 1 − cos θ sin θ a sin x + b cos x = a 2 + b 2 sin ( x + θ ) [ θ = arctan b a ] ∏ k = 1 n − 1 sin k π n = n 2 n − 1 ∏ k = 1 n − 1 cos k π n = sin n π 2 2 n − 1 tan α + tan β + tan γ = tan α tan β tan γ [ α + β + γ = k π ] sin 2 α + sin 2 β + sin 2 γ = 4 sin α sin β sin γ [ α + β + γ = π ] 1 = tan α tan β + tan β tan γ + tan γ tan α [ α + β + γ = ( k + 1 2 ) π ] {\displaystyle {\begin{aligned}\sin {(\alpha \pm \beta )}&=\sin {\alpha }\cos {\beta }\pm \cos {\alpha }\sin {\beta }\\\cos {(\alpha \pm \beta )}&=\cos {\alpha }\cos {\beta }\mp \sin {\alpha }\sin {\beta }\\\tan {(\alpha \pm \beta )}&={\frac {\tan \alpha \pm \tan \beta }{1\mp \tan \alpha \tan \beta }}\\\\\sin {2\theta }&=2\sin \theta \cos \theta ={\frac {2\tan \theta }{1+\tan ^{2}\theta }}\\\cos {2\theta }&=\cos ^{2}\theta -\sin ^{2}\theta ={\frac {1-\tan ^{2}\theta }{1+\tan ^{2}\theta }}\\\\\sin {3\theta }&=3\sin \theta -4\sin ^{3}\theta \\\cos {3\theta }&=4\cos ^{3}\theta -3\cos \theta \\\\\sin {(\alpha +\beta )}\sin {(\alpha -\beta )}&=\sin ^{2}\alpha -\sin ^{2}\beta \\\cos {(\alpha +\beta )}\cos {(\alpha -\beta )}&=\cos ^{2}\alpha -\sin ^{2}\beta \\\\\sin ^{2}\theta &={\frac {1-\cos {2\theta }}{2}}\\\cos ^{2}\theta &={\frac {1+\cos {2\theta }}{2}}\\\\\sin \alpha \sin \beta &=-{\cos(\alpha +\beta )-\cos(\alpha -\beta ) \over 2}\\\sin \alpha \cos \beta &={\sin(\alpha +\beta )+\sin(\alpha -\beta ) \over 2}\\\cos \alpha \cos \beta &={\cos(\alpha +\beta )+\cos(\alpha -\beta ) \over 2}\\\\\sin \alpha +\sin \beta &=2\sin {\frac {\alpha +\beta }{2}}\cos {\frac {\alpha -\beta }{2}}\\\sin \alpha -\sin \beta &=2\cos {\alpha +\beta \over 2}\sin {\alpha -\beta \over 2}\\\cos \alpha +\cos \beta &=2\cos {\frac {\alpha +\beta }{2}}\cos {\frac {\alpha -\beta }{2}}\\\cos \alpha -\cos \beta &=-2\sin {\alpha +\beta \over 2}\sin {\alpha -\beta \over 2}\\\\\sin {\theta \over 2}&=\pm {\sqrt {1-\cos \theta \over 2}}\\\cos {\theta \over 2}&=\pm {\sqrt {1+\cos \theta \over 2}}\\\tan {\theta \over 2}&=\pm {\sqrt {\frac {1-\cos \theta }{1+\cos \theta }}}={\frac {\sin \theta }{1+\cos \theta }}={\frac {1-\cos \theta }{\sin \theta }}\\\\a\sin {x}+b\cos {x}&={\sqrt {a^{2}+b^{2}}}\sin {(x+\theta )}\qquad [\;\theta =\arctan {b \over {a}}\;]\\\prod _{k=1}^{n-1}\sin {\frac {k\pi }{n}}&={\frac {n}{2^{n-1}}}\\\prod _{k=1}^{n-1}\cos {\frac {k\pi }{n}}&={\frac {\sin {\frac {n\pi }{2}}}{2^{n-1}}}\\\\\tan \alpha +\tan \beta +\tan \gamma &=\tan \alpha \tan \beta \tan \gamma \qquad [\alpha +\beta +\gamma =k\pi ]\\\sin {2\alpha }+\sin {2\beta }+\sin {2\gamma }&=4\sin \alpha \sin \beta \sin \gamma \qquad [\alpha +\beta +\gamma =\pi ]\\1&=\tan \alpha \tan \beta +\tan \beta \tan \gamma +\tan \gamma \tan \alpha \qquad [\alpha +\beta +\gamma =(k+{\frac {1}{2}})\pi ]\\\end{aligned}}}