B. Destruction of a Tree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any ot…
B. Destruction of a Tree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any ot…
codeforces 812E Sagheer and Apple Tree 题意 一棵带点权有根树,保证所有叶子节点到根的距离同奇偶. 每次可以选择一个点,把它的点权删除x,它的某个儿子的点权增加x.点权中途中不能为负.如果选中的是叶子节点,则只删除它的点权. 两个人玩博弈,后手可以先交换两个点点权,问有多少种方法使得他必胜? 题解 观察一下可以发现,把和叶节点同奇偶的那些点拉出来,相比nim博弈多了一种操作:增加一些石子在某堆.不过本质不会有什么变化,因为如果A选择增加,B可以选择减少相同的…
Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on. The girl noticed that some of the tree…
D. Ant on the Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for…
题目链接:http://codeforces.com/contest/799/problem/D 题意:给出h*w的矩阵,要求经过操作使得h*w的矩阵能够放下a*b的矩阵,操作为:将长或者宽*z[i] 有n个z[i]而且每个z[i]只能用一次. 题解:首先我们知道最少要扩大几倍, x = a / h + (a % h ? 1 : 0); y = b / w + (b % w ? 1 : 0); 当然要先排一下序从大到小,然后再是for一遍 pp *= z[i]; 如果pp>=x*y就是可行. 然…