GT and set  Accepts: 35  Submissions: 194  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 有NN个集合,每个集合中有A_iA​i​​个数. 你要将这NN个集合划成LL个部分,使得每个部分的集合至少有一个共有的数. 如果至少有一个解输出YESYES,否则输出NONO 输入描述 第一行一个数T表示数据组数.(TT\leq≤2020)…
bestcoder round#45 1003 题,给定两个点,要我们求这两个点的树上路径所经过的点的权值是否出现过奇数次.如果是一般人,那么就是用lca求树上路径,然后判断是否出现过奇数次(用异或),高手就不这么做了,直接树链剖分.为什么不能用lca,因为如果有树退化成链,那么每次询问的复杂度是O(n), 那么q次询问的时间复杂度是O(qn) 什么是树链剖分呢? 就是把树的边分成轻链和重链 http://blog.sina.com.cn/s/blog_6974c8b20100zc61.html…
zxa and leaf Problem Description zxa have an unrooted tree with n nodes, including (n−1) undirected edges, whose nodes are numbered from 1 to n. The degree of each node is defined as the number of the edges connected to it, and each node whose degree…
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=641&pid=1003 题意 : 给N集合, 每个集合由若干个正整数组成, 要求划分为L个部分, 使得每个部分的所有集合的交集非空 能划分输出YES, 否则NO 思路 : 一共N个集合, 划分的个数为1 - N个, 所以当 L > N 时必然是不行的 考虑如何取到最小的划分个数cnt, 如果 cnt <= L 则可行 方法 : 记录所有…
传送门 GTY's gay friends Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 264    Accepted Submission(s): 57 Problem Description GTY has n gay friends. To manage them conveniently, every morning he o…
题解  题目 1001 GT and sequence 注意先特判000的情况:如果读入的数据有000,那么去掉所有的000且最后答案和000取一个max. 剩下的正数显然全部乘起来比较优. 对于负数的话,如果个数是奇数个我们就去掉绝对值最小的那一个,然后全部乘起来即可. 1002 GT and numbers 如果AAA大于BBB那么显然无解. 考虑把AAA和BBB分解质因数. 若BBB存在AAA没有的质因数也显然无解. 对于某一个AAA的质因数的次数.为了加速接近BBB,它一定是每次翻倍,最…
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=641&pid=1002 思路 : N有若干个质因子, N = a^b * c^d * e^f...... M也有若干个质因子, M = a^(b+k) * c(d+k1) * e^(f+k2)...... N能到达M的条件是它们的质因子必须完全相同 N每次可以乘上它的若干个质因子, 直到这个质因子的幂次等于M这个质因子的幂次 考虑这样一个事实,…
LCIS  Accepts: 109  Submissions: 775  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 Alex有两个序列a1a2...ana​1​​,a​2​​,...,a​n​​和b1b2...bmb​1​​,b​2​​,...,b​m​​. 他想找到它们的最长公共递增子序列, 并且这个子序列的值是连续的(xx1...y1yx,x+1,...,y−…
Problem Description You are given two numbers NNN and MMM. Every step you can get a new NNN in the way that multiply NNN by a factor of NNN. Work out how many steps can NNN be equal to MMM at least. If N can't be to M forever,print −1-1−1. Input In t…
Problem Description You are given a sequence of NNN integers. You should choose some numbers(at least one),and make the product of them as big as possible. It guaranteed that the absolute value of any product of the numbers you choose in the initial…