Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher’s Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to grow a tree…
B. Grow The Tree Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wan…
http://codeforces.com/contest/842/problem/C 树 dp 一个数的质因数有限,用set存储,去重 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <time.h> #include <string> #include <set> #include <map>…
传送门 C. Ivan the Fool and the Probability Theory 题意: 给出一个\(n*m\)的方格,现在要给方格中的元素黑白染色,要求任一颜色最多有一个颜色相同的格子和它相邻.问多少种方案. 思路: 观察到若第一行含有两个相同的颜色相邻,那么之后所有格子的状态都可以确定: 若第一行不含有两个相同的颜色相邻,那么下一行至多有两种状态. 根据这两个观察,可以发现状态数其实不多,我们再推导一下: 对于第一种情况,假设第一个格子为白色,第二个格子有黑白两种选择:若选择白…
D. Catowice City In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are…
D2. The World Is Just a Programming Task (Hard Version) This is a harder version of the problem. In this version,…
A. Integer Points DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew…
A. Ivan the Fool and the Probability Theory Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To p…
Preface 这场CF真是细节多的爆炸,B,C,F都是大细节题,每道题都写了好久的说 CSP前的打的最后一场比赛了吧,瞬间凉意满满 希望CSP可以狗住冬令营啊(再狗不住真没了) A. Ivan the Fool and the Probability Theory 原谅我脑子不如陈指导好想不出来正解,然后打了个暴力3min找到规律做掉了... 然后讲一下正确的做法(陈指导教我的): 考虑我们用DP做出\(1\times m\)的矩阵的答案记为\(f_m\),考虑用它填了第一行 然后我们考虑第一…