That’s One Hanoi-ed Teacher 链接 题意: 询问一个汉诺塔的状态是否是最优的状态,如果是,询问还有多少步到最终状态. 分析: 考虑汉诺塔是怎么操作的,首先是考虑F(i)是有i个盘子,从一根柱子完全移到另一根柱子的花费.如果存在x个盘子,那么答案是F(x - 1)+1+F(x-1),为前x-1盘子先从1移动到2,然后第x个盘子移动到3,然后x-1个盘子从2移到3. 所以对于一个状态,可以先找到最大的盘子x,如果在中间的话,无解.否则使用F(x-1)+1次操作,将它移动到应…
CF Gym 102028G Shortest Paths on Random Forests 抄题解×1 蒯板子真jir舒服. 构造生成函数,\(F(n)\)表示\(n\)个点的森林数量(本题都用EGF).怎么求呢 \(f(n)=n^{n-2}\)表示\(n\)个点的树数量,根据\(\exp\)定义,\(e^x=\sum_{i=0}^{\infty}\frac{x^i}{i!}\).那么\(F=\exp f\),感性理解就是如果选\(i\)个联通块拼起来就除以\(i!\),很对的样子. 那么期…
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/G Description An owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to partic…
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G Description After landing on planet i1c5l people noticed that blue and black clothes are quite popular among the locals. Each aboriginal has at least…
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/G Description An owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to partic…
题目:http://codeforces.com/gym/101933/problem/K 其实每个点的颜色只要和父亲不一样即可: 所以至多 i 种颜色就是 \( i * (i-1)^{n-1} \),设为 \( f(i) \),设恰好 i 种颜色为 \( g(i) \) 那么 \( f(i) = \sum\limits_{j=0}^{i} C_{i}^{j} * g(j) \) 二项式反演得到 \( g(i) = \sum\limits_{j=0}^{k} (-1)^{k-j} * C_{k}…
题目链接:http://codeforces.com/gym/101147/problem/G G. The Galactic Olympics time limit per test 2.0 s memory limit per test 64 MB input galactic.in output standard output Altanie is a very large and strange country in Mars. People of Mars ages a lot. So…
http://codeforces.com/gym/100952/problem/G G. The jar of divisors time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Alice and Bob play the following game. They choose a number N to play with.…
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87954#problem/G Description You are given a sequence A consisting of N integers. We will call the i-th element good if it equals the s…
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87954#problem/G Description You are given a sequence A consisting of N integers. We will call the i-th element good if it equals the s…