传送门: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…
题意:给出一棵n个节点的树,每个节点有一个权值,Q和T玩游戏,Q先选一些不相邻的节点,T选剩下的节点,每个人的分数是所选节点的权值的异或和,权值大的胜出,问胜出的是谁. 题解: 话说,这题后面的边跟解的过程半毛钱关系没有,但是自己就是想不到,这博弈... 设sum为所有点权的异或和,A为先手得分,B为后手得分. 若sum=0,则A=B,故无论如何都是平局. 否则考虑sum二进制下最高的1所在那位,一定有奇数个点那一位为1.若先手拿走任意一个那一位为1的点,则B该位为0,故先手必胜. #inclu…
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…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322 Problem Description In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n that are relatively prime to n . It can be defined more formally as the number…
链接: https://www.nowcoder.com/acm/contest/139/F 题意: 分析: 转载自:http://tokitsukaze.live/2018/07/19/2018niuke1.F/ 代码: #include <cstdio> #include <cassert> #include <algorithm> using namespace std; /// 注意mod,使用前须调用一次 polysum::init(int M); names…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6331 Walking Plan  Problem Description There are n intersections in Bytetown, connected with m one way streets. Little Q likes sport walking very much, he plans to walk for q days. On the i -th day, Little…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6325                                   Interstellar Travel Problem Description After trying hard for many years, Little Q has finally received an astronaut license. To celebrate the fact, he intends to buy…
Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.  Given a time in Beijing time (UTC +8), Chiaki would like to know the time in another time zone ss. Input There are multiple test cases.…
hiaki has an array of nn positive integers. You are told some facts about the array: for every two elements aiai and ajaj in the subarray al..ral..r (l≤i<j≤rl≤i<j≤r), ai≠ajai≠aj holds.  Chiaki would like to find a lexicographically minimal array whi…