https://codeforces.com/contest/1330/problem/D 题目大意:给出一个限制 d 与模数 m ,求出可以构造出的满足条件的数组 a 的个数,需要满足以下条件:    1.数组 a 的长度大于等于 1     2.数组 a 严格递增    3.任意的ai <=d且>=1    4.对于数组 a ,需要构造出一个数组 b :满足当 i == 1 时:b[ 1 ] = a[ 1 ], i > 1 时:b[ i ] = b[ i - 1 ] XOR a[ i…
题目连接:Dreamoon Likes Sequences  题意:给你d和m,让你构造一个递增数组a,使数组b(i==1,b[i]=a[i] ; i>1, b[i]=b[i-1]^a[i])递增,求a有几种,答案模m. 题解:根据异或的性质可以得出:2后边不能有3, 4后边不能有5~7, 8后边不能有9~15...... 然后就很好写了.用数组b记录第i个数可以取得数有多少个,数组dp记录长度为 i 的 a 数组有几种.看下边的代码应该就清楚了. 1 #include<bits/stdc++…
题目链接 题目大意 让你构造一个严格单调上升的数组a满足\(1<=a_1<a_2<....a_n<=d\) 而且要使得这个数组的异或前缀和也满足严格单调上升,求有多少个满足条件的数组(mod m) 题目思路 首先这个数组的性质很容易观察就是后一个数化为二进制的最高位1要比第上一个高 然后我就不会了 我还以为是枚举数组长度啥的,果然是我太菜了 这种类型的题目需要求贡献.枚举位数为 i 的数是否在序列中出现并计算对答案的贡献,根据乘法原理相乘即答案. 当位数小于log(d)的位数,贡献…
http://codeforces.com/contest/816/problem/E 题意: 去超市买东西,共有m块钱,每件商品有优惠卷可用,前提是xi商品的优惠券被用.问最多能买多少件商品? 思路: 第一件商品使用优惠券不需要前提,别的都是需要的,然后这样就形成了一棵以1为根的树. 这样,很容易想到是树形dp. d[u][j][0/1]表示以u为根的子数中选择j件商品所需的最少花费,0/1表示u商品是否能用优惠券. 解释一下代码中的sz[],它所代表的是以u为根的子树的结点数. 当我们现在访…
题目链接 D. Appleman and Tree time limit per test :2 seconds memory limit per test: 256 megabytes input :standard input output:standard output Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices a…
C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password i…
传送门 题意 给出三个集合,每个集合的元素数量为a,b,c,现在需要连边,满足集合内元素不可达或最短路为3,求可行方案数 分析 设dp[i][j]为a集合元素为i个,b集合元素为j个的可行方案,易知(a,b),(b,c),(c,a)的方案是独立的,且可行方案为a->b->c,或旋转形式,那么就求一个两个集合的连边方案数即可. 转移方程 dp[i][j]=dp[i-1][j]+dp[i-1][j-1]*j; trick 代码 #include <bits/stdc++.h> usin…
B. Name That Tune time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output It turns out that you are a great fan of rock band AC/PE. Peter learned that and started the following game: he plays the f…
D. Nauuo and Circle •参考资料 [1]:https://www.cnblogs.com/wyxdrqc/p/10990378.html •题意 给出你一个包含 n 个点的树,这 n 个点编号为 1~n: 给出一个圆,圆上放置 n 个位置,第 i 个位置对应树中的某个节点,并且不重复: 求在圆上还原这棵树后,使得边不相交的总方案数: •题解 ①为何每一颗子树一定是连续的一段圆弧? 假设不是连续的圆弧,如图所示: 为了使 x 接到树上,必然会有 x-y 或 x-z 相连的边,这样…
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to becom…