考虑两个灯之间的暗灯,能从左边或右边点亮两种顺序,而最左端或最右端只有一种点亮顺序. 先不考虑点灯顺序,总共有n - m个灯要点亮,对于连续的一段暗灯,他们在总的点灯顺序中的是等价的,于是问题就可以抽象成有重复元素的组合数: $ C = \frac{ (n - m)! }{ \prod_{i = 1}^{k} \, x_{i} ! }  $ . 在考虑一段连续的暗灯内部的点灯顺序,只要让答案乘上 $ 2 ^ {len - 1} $ 即可. $ \bigodot $ 技巧&套路: 组合数应用的模型…
题目描述 There are n n n lights aligned in a row. These lights are numbered 1 1 1 to n n n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light shoul…
http://codeforces.com/contest/294/problem/C 把那个数组n分段了,那么有两类. 1.开头和端点那些,就是只有一端在开始的,这个时候,要开完这些灯,只能循序渐进,1--2--3--4 2.第二类就是中间那些,两端都可以开始,那些段的开灯次数是2^(len - 1).因为这个就是看成一个双端队列,每一次都可以从头或者尾取数字,所以每次的决策有2种,然后最后一次只有一个数,所以直接是它. 现在就是把他们若干段合并后,有多少种情况的问题了. 其实就是 A1.B1…
题目大意: 有n盏灯,(0<=n<=1000),有m盏已经点亮,每次只能点亮与已经点亮的灯相邻的灯,求总方案数,答案对1e9+7取模 第一行:两个整数n,m表示灯的总数和已点亮的灯的数目 第二行m个数,表示已点亮的灯的编号 分析: 我们可以借助已经被点亮的灯作为分界点,找到若干个长度不为0的开区间. 对于两边都有开着的灯的区间,我们点亮它每次可以点亮最左边一盏或者最右边一盏,而最后一盏灯只有一种方法,所以点亮长度为len的区间的方案数为:2^(len-1) 特别地,对于两端的区间(一边有灯开着…
A. Shaass and Oskols 模拟. B. Shaass and Bookshelf 二分厚度. 对于厚度相同的书本,宽度竖着放显然更优. 宽度只有两种,所以枚举其中一种的个数,另一种的个数是单调的. C. Shaass and Lights 考虑一段连续未点亮的灯,显然每次操作都只会将区间长度减一,继而推得长度L的方案数为\(2^{L - 1}\)种. 考虑有若干段Li合并,对于一个区间来说,内部的操作顺序应该是相对不变的,那么就是挖空填即可. 注意判断两端的状态,即考虑1.n的状…
poj1112 Team Them Up! 补图二分图+dp记录路径codeforces 256A Almost Arithmetical Progression dp或暴力 dp[i][j] = dp[j][last] + 1 ;codeforces 294C Shaass and Lights 组合 计算方法的优化codeforces 298C Parity Game 纯粹证明题,想法很好.codeforces 256D 还不会,很好的一个dppoj3417 Network LCA + 树形…
题目链接:http://codeforces.com/contest/294/problem/B B. Shaass and Bookshelf time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Shaass has n books. He wants to make a bookshelf for all his books.…
Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is ti and its pages' width is equal to wi. The thickness of each book is either 1 or 2.…
cf711D 成环的和不成环的要单独计算,环用双联通做的QAQ /* 所有情况-成环的情况 */ #include<bits/stdc++.h> using namespace std; #define maxn 200005 #define mod 1000000007 #define ll long long ]; int n,head[maxn],tot; ll ans; void init(){ memset(head,-,sizeof head); tot=; } void adde…
状压+暴力搜索 Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 178    Accepted Submission(s): 57 Problem Description Harry: "But Hagrid. How am I going to pay for all of this? I h…