正文
增加 11 行删除 11 行
133 行未改动全部展开13413513613713813914014114236 行未改动17918018118218318418518618718818919019119219319419519619719819920016 行未改动21721821922022122222322422521 行未改动133 行未改动全部展开定义状态是 $dp_{n,k}$,表示有 $n$ 个节点,深度为 $k$ 的方案数。 我的状态和这个一样。那么考虑去转移,设当前的左子树有 $x$ 个节点,则右子树有 $n-x+1$ 个节点则有 $dp_{n,k}= \sum_{x=0}^{n} dp_{x,k-1} \times dp_{n-x-1,k-1} $考虑到有可能有些情况是转移不了的,就是无法用 $n$ 个结点拼 $k$ 层的情况(不够或超过)。实际上这些值会有贡献。那么正确的状态设计其实是:有 $n$ 个结点时,深度不超过 $k$ 的方案数。36 行未改动我在代码上注释写了一部分我的思路,后来又想到可以到这里写思路了。A naive idea is that travel 1-inf by icheck if i is a humbel numberand count n numbersin the worst case:each element in S is discrete, so our plan will travel many uselees numbersconsider the constructionassume we had constructed previous n-1 numbersthe n-th number is :1. new from set S and it has not been used , so a[n] = S[t]2. construct from a[1 ~ n-1] , so a[n] = a[1 ~ n-1] * S[1 ~ t-1]16 行未改动#### [Stringsobits](https://usaco.training/usacoprob2?a=lVemSxElHGn&S=kimbits)看了很久不会做。看了题解没想到是个 dp考虑递推,记 dp[i][j] 为 i 位二进制数中有 j 个 1 的数有多少个。转移就考虑最高位是否放 1,dp[i][j] = dp[i-1][j] + dp[i-1][j-1]考虑完方案数,那么第 m 小的数字的第 x 位 1 应该满足 m > dp[x][y]21 行未改动133 行未改动全部展开13413513613713813914014114236 行未改动17918018118218318418518618718818919019119219319419519619719819920016 行未改动21721821922022122222322422521 行未改动133 行未改动全部展开定义状态是 $dp_{n,k}$,表示有 $n$ 个节点,深度为 $k$ 的方案数。 我的状态和这个一样。那么考虑去转移,设当前的左子树有 $x$ 个节点,则右子树有 $n-x+1$ 个节点则有 $dp_{n,k}= \sum_{x=0}^{n} dp_{x,k-1} \times dp_{n-x-1,k-1} $考虑到有可能有些情况是转移不了的,就是无法用 $n$ 个结点拼 $k$ 层的情况(不够或超过)。实际上这些值会有贡献。那么正确的状态设计其实是:有 $n$ 个结点时,深度不超过 $k$ 的方案数。36 行未改动我在代码上注释写了一部分我的思路,后来又想到可以到这里写思路了。A naive idea is that travel 1-inf by icheck if i is a humbel numberand count n numbersin the worst case:each element in S is discrete, so our plan will travel many uselees numbersconsider the constructionassume we had constructed previous n-1 numbersthe n-th number is :1. new from set S and it has not been used , so a[n] = S[t]2. construct from a[1 ~ n-1] , so a[n] = a[1 ~ n-1] * S[1 ~ t-1]16 行未改动#### [Stringsobits](https://usaco.training/usacoprob2?a=lVemSxElHGn&S=kimbits)看了很久不会做。看了题解没想到是个 dp考虑递推,记 dp[i][j] 为 i 位二进制数中有 j 个 1 的数有多少个。转移就考虑最高位是否放 1,dp[i][j] = dp[i-1][j] + dp[i-1][j-1]考虑完方案数,那么第 m 小的数字的第 x 位 1 应该满足 m > dp[x][y]21 行未改动