A. Lengthening Sticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of…
传送门:点我 A. Lengthening Sticks  time limit per test        1 second You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different s…
题意:三角形3条边,最多共添加ll长,问组成的合法三角形个数. 本来想用暴搜,觉得会超时就搜题解了.不过保证我解释得更清晰. 先计算ll长分配给3条边有几种分法?由于不分也是合法的,因此最后实际分出去的量从0-ll都有可能.for循环枚举实际分的量(记为i).对于每个x,分为m,p,q三份(每份可为0),相当于x+3分为,m+1,p+1,q+1(每份不可为0),相当于x+3长度上(中间只有x+2个间隔,选2个)切不同的两刀.因此就是循环(x+2)*(x+2-1)/(2*(2-1)); 然后计算分…
题目大意: a,b,c三根木棍可以增加三个不同的数字,aa,bb,cc,且aa+bb+cc<=L,问能构成三角形的木棒有多少种方案 题目思路: 如果我们直接考虑把L分配给aa,bb,cc好像不好下手 所以逆向考虑 合法的情况  =  所有情况 - 不合法的情况 step1: 首先计算所有的情况 假设L当时为l 我们把长度为l分配去的总的方案 这个问题我们等效为:有三个篮子,每个篮子放至少一个个物品,总共l个物品,问有多少种方案 我们用插板法解决这个问题 因为每个篮子放至少一个,而我们的目标是可以…
4710: [Jsoi2011]分特产 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 289  Solved: 198[Submit][Status][Discuss] Description JYY 带队参加了若干场ACM/ICPC 比赛,带回了许多土特产,要分给实验室的同学们. JYY 想知道,把这些特产分给N 个同学,一共有多少种不同的分法?当然,JYY 不希望任 何一个同学因为没有拿到特产而感到失落,所以每个同学都必须至少分得一个特产.…
题目链接: http://codeforces.com/problemset/problem/451/E E. Devu and Flowers time limit per test4 secondsmemory limit per test256 megabytes 问题描述 Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flow…
3622: 已经没有什么好害怕的了 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 1033  Solved: 480[Submit][Status][Discuss] Description Input Output Sample Input 4 25 35 15 4540 20 10 30 Sample Output 4 HINT 输入的2*n个数字保证全不相同. 还有输入应该是第二行是糖果,第三行是药片 考虑dp两个数组排序,可以求出有m组糖…
题目链接 \(Description\) 给定\(n\)个正整数\(a_i\).求有多少个子序列\(a_{i_1},a_{i_2},...,a_{i_k}\),满足\(a_{i_1},a_{i_2},...,a_{i_k}\) \(and\)起来为\(0\). \(n\leq10^6,\quad 0\leq a_i\leq10^6\). \(Solution\) 这个数据范围..考虑按位容斥: 令\(g_x\)表示\(x\)的二进制表示中\(1\)的个数,\(f_x\)表示有多少个\(a_i\)…
题目链接 \(Description\) 棋盘上\((0,0)\)处有一个棋子.棋子只有两种走法,分别对应向量\((A_x,A_y),(B_x,B_y)\).同时棋盘上有\(n\)个障碍点\((x_i,y_i)\),棋子在任何时刻都不能跳到障碍点. 求棋子从\((0,0)\)跳到\((E_x,E_y)\)的方案数.答案对\(10^9+7\)取模. \(Solution\) 注意到\(A_x*B_y-A_y*B_x\neq0\),即两向量不共线,从某个点走到另一个点,两种方式分别所用次数\(x,y…
大意: 给定集合a, 求a的按位与和等于0的非空子集数. 首先由容斥可以得到 $ans = \sum \limits_{0\le x <2^{20}} (-1)^{\alpha} f_x$, 其中$\alpha$为$x$二进制中$1$的个数, $f_x$表示与和等于$x$的非空子集数. $f_x$是一个$20$维前缀和, 按传统容斥做法的话显然要超时, 可以每次求一维的和, 再累加 比方说对于2维前缀和, 用容斥的求法是这样 for (int i=1; i<=n; ++i) { for (in…