首页 > 其他分享 >CF755G PolandBall and Many Other Balls

CF755G PolandBall and Many Other Balls

时间:2023-07-20 18:46:55浏览次数:39  
标签:Balls log Many CF755G Other PolandBall

列出转移方程就是傻鸟题了,具体地,令 \(f_{i,j}\) 为前 \(i\) 球取出 \(j\) 组的方案数,有:

\[f_{i,j}=f_{i-1,j-1}+f_{i-1,j}+f_{i-2,j-1} \]

列出 \(f_{i}\) 的 GF \(F_i(x)\):

\[F_i(x)=F_{i-1}(1+x)+F_{i-2}\cdot x \]

这是递推,把矩阵元素改成多项式,矩阵快速幂即可。\(O(k\log k\log n)\)。

标签:Balls,log,Many,CF755G,Other,PolandBall
From: https://www.cnblogs.com/Ender32k/p/17569360.html

相关文章

  • 题解 Yet Another Minimization Problem
    YetAnotherMinimizationProblem神仙题。第一眼看上去就是DP。定义\(f_{i,j}\)表示当前点\(i\),分\(j\)段的最小费用。\(f_{i,j}=\min(f_{i,j},f_{k,j-1}+val_{k+1,i})\)然后发现复杂度\(O(n^2k)\),直接T飞,需要优化。我们发现\(j\)那一维可以滚掉,也就是只考虑第......
  • AtCoder Grand Contest 012 D Colorful Balls
    洛谷传送门AtCoder传送门不错的题。bxEnder32k。我们发现交换有传递性,那么我们能交换就连边,答案是\(\prod\frac{(sz)!}{\prodc_i!}\),其中\(sz\)为连通块大小,\(c_i\)为这个连通块中第\(i\)种颜色出现次数。于是我们得到了一个\(O(n^2)\)的做法。发现很多遍是无用的......
  • [Algorithm] Two crystal balls problem
    You'regiventwoidenticalcrystalballsanda100-storybuilding.Theballsareincrediblytough,butthereexistssomefloorinthebuilding,abovewhichtheballswillbreakwhendropped,andbelowwhichtheywillnot.Youdon'tknowwhatthi......
  • AtCoder Grand Contest 058 D Yet Another ABC String
    洛谷传送门AtCoder传送门OrzH6_6Q,感谢他给我们带来了这道容斥好题。这个东西看起来很不好搞。可以尝试容斥。但是我们要容斥啥?钦定ABC不出现,其他任意?感觉还是很难算。观察不合法子串,发现它们很有特点。如果我们钦定\(\texttt{A}\)为\(0\),\(\texttt{B}\)为\(1\),\(\te......
  • VMware:Package vim is not available, but is referred to by another package.
    出错语句在ubuntu中输入sudoapt-getinstallvim安装vim时出现如下错误语句Readingpackagelists...DoneBuildingdependencytreeReadingstateinformation...DonePackagevimisnotavailable,butisreferredtobyanotherpackage.Thismaymeanthatt......
  • YetAnotherRGBSequence
    [ABC266G]YetAnotherRGBSequence为了方便将\(r,g,b\)替换为\(a,b,c\)。考虑可以将\(a-=k,b-=k\),就变为\(a-k\)个\(a\),\(b-k\)个\(b\),\(c\)个\(c\),\(k\)个\(ab\),(这里我们已经将\(a,b\)减去\(k\),下文的\(a,b\)均指代减去后的结果)然后求排列总数,使得不构成新......
  • Cross-thread operation not valid: Control 'txtMessage' accessed from a thread ot
    WinformTextBox Cross-threadoperationnotvalid:Control'txtMessage'accessedfromathreadotherthanthethreaditwascreatedon. (330条消息)解决Cross-threadoperationnotvalid的问题_GuanXX的博客-CSDN博客  privatevoidsafeSetText(stringt......
  • 什么是 Kernel Smoother ?它与 Self Attention 有什么关系?
    [1]带权滑动平均(WeightedMovingAverage,WMA)是标量场上的滑动窗口内的加权平均,数学上等价于卷积。[1][2]KernelSmoother是一种特殊的WMA方法,特殊在于权重是由核函数决定的,相互之间越接近的点具有越高的权重。[2][3]Transformer中的自注意力机制可以看作一种KernelS......
  • CodeTON Round 5 (Div. 1 + Div. 2, Rated, Prizes!) C. Tenzing and Balls
    一开始以为是贪心,后来发现不好贪于是选择了dp,但是dp有个小细节没注意到,后面wa了几发我们以状态来分,f[i]表示考虑i的最大区间合长度,每次转移的时候考虑两种情况,一种是a[i]前面有一样的数字,比较选了a[i]和不选a[i]两种情况下的最大值,还有一种就是a[i]为第一个出现的数字则选区间长......
  • F. Bags with Balls 第二类斯特林数
    BagswithBalls标号为奇数的个数为\(c=\frac{m+1}{2}\)标号为偶数个数为\(w=m-c\)答案显然为\(ANS=\sum_{i=1}^{n}C(n,i)c^iw^{n-i}i^k\)直接算是\(O(n)\)的,但这道题\(n\)为\(1e9\)考虑第二类斯特林数化简\(i^k\)\(x^k=\sum_{i=1}^kC(x,i)s(k,i)i!\)\(ANS=\sum_{i=1}^{n}C......