@codeforces - 717A@ Festival Organization】的更多相关文章

目录 @description@ @solution@ @accepted code@ @details@ @description@ 一个长度为 n 的 01 序列是好的,当且仅当该序列任意两个 0 不相邻. 求从 [l, r] 中选出 k 个长度相等的 01 序列的方案数. 1 ≤ k ≤ 200, 1 ≤ l ≤ r ≤ 10^18. 原题戳这里 @solution@ 定义 f[i] 表示合法 01 串数量,对最后一个是 1 还是 0 进行讨论得到 f[i] = f[i-1] + f[i-…
题目:http://codeforces.com/contest/717/problem/A 是 BJOI2019 勘破神机 的弱化版. 令 \( g[i] \) 表示长为 i .以 1 结尾的方案数,有 \( g[i]=g[i-1]+g[i-2] , g[0]=g[1]=1 \) : 令 \( f[i] \) 表示长为 i 的方案数,有 \( f[i]=g[i]+g[i-1] \) 发现 \( f[i]=f[i-1]+f[i-2] , f[0]=1 , f[1]=2 \) 那么令 l+=2 ,…
\(CF717\ Festival\ Organization\) Description 一个合法的串定义为:长度在 \([l,r]\) 之间,且只含 \(0,1\),并且不存在连续 \(2\) 个或更多的 \(0\). 现在要选出 \(k\) 个长度相同的合法的串,问有几种选法,答案模 \(10^9+7\). Solution 初始形式比较易得 \[\sum_{i=l+2}^{r+2}\binom{fib_i}{k} \] 开始化式子 \[\sum_{i=l+2}^{r+2}\frac{fa…
题目大意:求 $\sum\limits_{n=l}^{r}\dbinom{f_n}{k}\bmod 10^9+7$.其中 $f_n$ 是长度为 $n$ 的 $01$ 序列中,没有连续两个或超过两个 $0$ 的个数. $1\le k\le 200,1\le l\le r\le 10^{18}$. 先考虑如何求 $f_n$. 令 $g[i][j]$ 表示长度为 $i$,结尾是 $j$ 的序列个数. $$g[i][0]=g[i-1][1]$$ $$g[i][1]=g[i-1][0]+g[i-1][1]…
E. Thoroughly Bureaucratic Organization 题目连接: http://www.codeforces.com/contest/201/problem/E Description Once n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TB…
link:http://codeforces.com/problemset/problem/340/C 开始一点也没思路,赛后看别人写的代码那么短,可是不知道怎么推出来的啊! 后来明白了. 首先考虑第一个数字,就是和0想减的内个.那么剩下的n-1个数字有(n-1)!个排列方式.所以呢,在n!个式子里面,第一个位置的和就是:a1 * (n-1)! + a2 * (n-1)! + ...... + an * (n-1)!: 然后考虑其它位置:对于ai , aj . 并且相邻.那么剩下 n - 2 个…
题目链接:http://codeforces.com/contest/327/problem/C 首先先算出一个周期里面的值,保存在ans里面,就是平常的快速幂模m做法. 然后要计算一个公式,比如有k个部分,那么对于没一个位置i, 都有2^i + 2^(i+n) + ... + 2^(i+(k-1)*n) = 2^i(1 + 2^n + ... + 2^((k-1)*n)) = 2^i * (1-2^(n*k))/(1-2^n) 所以结果就是ans * (1-2^(n*k))/(1-2^n) %…
http://codeforces.com/contest/373/problem/E E. Watching Fireworks is Fun time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output A festival will be held in a town's main street. There are n sectio…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…