Problem F. Grab The Tree HDU - 6324】的更多相关文章

题意:给出一棵n个节点的树,每个节点有一个权值,Q和T玩游戏,Q先选一些不相邻的节点,T选剩下的节点,每个人的分数是所选节点的权值的异或和,权值大的胜出,问胜出的是谁. 题解: 话说,这题后面的边跟解的过程半毛钱关系没有,但是自己就是想不到,这博弈... 设sum为所有点权的异或和,A为先手得分,B为后手得分. 若sum=0,则A=B,故无论如何都是平局. 否则考虑sum二进制下最高的1所在那位,一定有奇数个点那一位为1.若先手拿走任意一个那一位为1的点,则B该位为0,故先手必胜. #inclu…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6324 Problem F. Grab The Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1234    Accepted Submission(s): 779 Problem Description Little Q and…
6324.Problem F. Grab The Tree 题目看着好难,但是题解说的很简单,写出来也很简单.能想出来就是简单的,想不出来就难(讲道理,就算是1+1的题目,看不出来就是难的啊). 和后面的东西一点关系都没有... 官方题解: 设sum为所有点权的异或和,A为先手得分,B为后手得分. 若sum=0,则A=B,故无论如何都是平局. 否则考虑sum二进制下最高的1所在那位,一定有奇数个点那一位为1.若先手拿走任意一个那一位为1的点,则B该位为0,故先手必胜. 时间复杂度O(n). 代码…
Little Q and Little T are playing a game on a tree. There are n vertices on the tree, labeled by 1,2,...,n , connected by n−1 bidirectional edges. The i -th vertex has the value of wi .In this game, Little Q needs to grab some vertices on the tree. H…
题目链接: Problem: Query on the tree Time limit: 1s     Mem limit: 64 MB      Problem Description There is a tree with n node, labeled from 1 to n, and the root of the tree is 1. For every node i, if its father is j, its value vi=vj*i%20161119, the value…
Home Web Board ProblemSet Standing Status Statistics   Problem F: 求平均年龄 Problem F: 求平均年龄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 720  Solved: 394[Submit][Status][Web Board] Description 定义一个Persons类,用于保存若干个人的姓名(string类型)和年龄(int类型),定义其方法 void ad…
Problem F Funny Car Racing There is a funny car racing in a city with n junctions and m directed roads. The funny part is: each road is open and closed periodically. Each road is associate with two integers (a, b), that means the road will be open fo…
Problem F. Door LockTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description It was a beautiful night at Yekaterinburg, the sky was crystal clear with no clouds, and the view of the moon and the stars was…
Problem F "Folding" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description Bill is trying to compactly represent sequences of capital alphabetic characters from 'A' to 'Z' by folding repeating subsequences insid…
Problem F. Fibonacci SystemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86821#problem/B Description Little John studies numeral systems. After learning all about fixed-base systems, he became inte…