题意:长度为n的序列,相邻两个或单独一个可以划分到一个组,每个元素最多处于一个组. 问恰好分割成k(1<=k<=m)段有多少种方案? 标程: #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; ; int l,_n,pos[N],n,k,a[N],b[N],c[N],x1[N],x2[N],x3[N],x4[N],w[N],wn,inv_n; int ksm(int x,int y) { ;…
题面 CF755G PolandBall and Many Other Balls 给定 \(n\) 和 \(m\).有一排 \(n\) 个球,求对于每个 \(1\le k\le m\),选出 \(k\) 个球或相邻的球不能重复的方案数. 数据范围:\(1\le n\le 10^9\),\(1\le m<2^{15}\). 路标 这题是老经典题了,前人的描述也足够充分了. 但是蒟蒻尝试了这题的 \(3\) 种做法并记在笔记中后还是忍不住去挣咕值分享给大家. 这是的三种做法对比图(从下到上依次是倍…
从神 Karry 的题单过来的,然后自己瞎 yy 了一个方法,看题解区里没有,便来写一个题解 一个常数和复杂度都很大的题解 令 \(dp_{i,j}\) 为 在 \(i\) 个球中选 \(j\) 组的方案数,则显然有转移 \(dp_{i,j}=dp_{i-1,j}+dp_{i-1,j-1}+dp_{i-2,j-1}\) 然后考虑对其优化: 令 \(f_i\) 为 \(dp_i\) 的生成函数,则 \(f_i\) 只与 \(f_{i-1}\) 和 \(f_{i-2}\) 有关,且关系为 \(f_i…
因为垃圾电脑太卡了就重开了一个... 前传:多项式Ⅰ u1s1 我预感还会有Ⅲ 多项式基础操作: 例题: 26. CF438E The Child and Binary Tree 感觉这题作为第一题还蛮合适的( 首先我们设 \(f_i\) 为权值之和为 \(i\) 的符合要求的二叉树的个数. 显然可以枚举根节点的权值.左子树的权值之和进行转移. 也就是 \(f_i=\sum\limits_{x\in S}\sum\limits_{y=0}^{i-S}f_yf_{i-x-y}\) 如果我们记 \(…
Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9641 Accepted: 2636 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share the…
-----------------------------最优化问题------------------------------------- ----------------------常规动态规划  SOJ1162 I-Keyboard  SOJ1685 Chopsticks SOJ1679 Gangsters SOJ2096 Maximum Submatrix  SOJ2111 littleken bg SOJ2142 Cow Exhibition  SOJ2505 The County…
C. PolandBall and Forest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graph…
题目链接: F. PolandBall and Gifts time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output It's Christmas time! PolandBall and his friends will be giving themselves gifts. There are n Balls overall.…
F. PolandBall and Gifts   It's Christmas time! PolandBall and his friends will be giving themselves gifts. There are n Balls overall. Each Ball has someone for whom he should bring a present according to some permutation p, pi ≠ i for all i. Unfortun…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already sa…