[链接]h在这里写链接 [题意] 给你一棵树,每个节点上都有一个权值. 然后给你m个询问,每个询问(x,y,a,b); 表示询问x->y这条路径上权值在[a,b]范围内的节点的权值和. [题解] 树链剖分题. 在树链上建一个线段树,线段树的每个节点存3个值,max[i],min[i],sum[i]分别表示这个区间里面的数的最大值.最小值.以及权值和. 然后在线段树上做查找(a,b)范围内的数的权值和. 如果该节点在路径上,那么如果a<=min[i] && max[i] <…
[链接]点击打开链接 [题意] 询问n个点的完全k叉树,所有子树节点个数的异或总和为多少. [题解] 考虑如下的一棵k=3叉树,假设这棵树恰好有n个节点. 因为满的k叉树,第i层的节点个数为k^(i-1); 则我们找到最大的d; 使得 k^0+k^1+..+k^(d-1) <=n 自此,我们会发现,整棵树可以分成若干个树的深度大小为d和d-1的满k叉树. 如上图,d=3,两个圈起来的,就是一个深度为3的满k叉树和一个深度为2的满k叉树. 当然,还可能会有一个子树,它不是满的k叉树. 如上图中没有…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6162 [算法] 离线树剖 我们知道,u到v路径上权值为[A,B]的数的和 = u到v路径上权值小于等于B的数的和 - u到v路径上权值小于等于(A-1)的数的和 不妨将询问拆开,离线计算答案即可 [代码] #include<bits/stdc++.h> using namespace std; ; int i,n,m,u,v,now,timer,tot,cnt; long long l,r;…
Funny Function Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1109    Accepted Submission(s): 527 Sample Input 2 2 2 3 3 Sample Output 2 33 Source 2017 Multi-University Training Contest - Team…
TrickGCD Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2097    Accepted Submission(s): 816 Sample Input 1 4 4 4 4 4 Sample Output Case #1: 17   Source 2017 Multi-University Training Contest…
Maximum Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1450    Accepted Submission(s): 673 Sample Input 4 8 11 8 5 3 1 4 2 Sample Output 27 Hint For the first sample: 1. Choose 2 from…
Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2004    Accepted Submission(s): 795 Problem Description On a two-dimensional plane, give you n integer points. Your task is to fig…
[链接]点击打开链接 [题意] 给你一个面积,让你求围成这个面积最少需要几条边,其中边的连线只能是在坐标轴上边长为1的的线或者是两个边长为1 的线的对角线. [题解] 找规律题 考虑s[i]表示i条边能组成的最大面积. s[6]=4. s[7]=4+1.5=5.5 s[8]=4+4=8 s[9]=8+1.5=9.5 s[10]=8+4=12 s[11]=12+2.5=14.5 s[12]=12+=18 之后又重复一遍..s[13]=18+2.5,s[14]=18+6 可以发现,一开始x1 = 1…
[链接]点击打开链接 [题意] 有人写了一个最小点覆盖的贪心算法,然后,让你去hack它. 并且,要求这个算法得到的错误答案,是正确答案的三倍. 让你任意输出hack数据,点数<=500 [题解] 最小点覆盖->二分图? 程序中有这么一段 if (deg[i] >= mx) { mx = deg[i]; u = i; } 也就是说,如果有多个度数最大的,它会选择标号最大的那一个. 这就是我们构造出答案的基础. 我们可以把二分图的左右两个部分各加N个点. 然后右边的点依次标号为N+1,N+…
Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 652    Accepted Submission(s): 267 Sample Input 3 2 1 0 2 0 1 3 4 2 0 1 0 2 3 1 Sample Output Case #1: 4 Case #2: 4 Source 2017 Multi-U…
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1060    Accepted Submission(s): 506 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any oth…
Dying Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 513    Accepted Submission(s): 122 Problem Description LsF is visiting a local amusement park with his friends, and a mirror room su…
CSGO Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 127    Accepted Submission(s): 20 Problem Description Senior Pan is crazy about CSGO and she is so skilled. She can kill every enemy she sp…
Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1354    Accepted Submission(s): 496 Problem Description Mr. Cui is working off-campus and he misses his girl friend very much. After a w…
Big binary tree Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 597    Accepted Submission(s): 207 Problem Description You are given a complete binary tree with n nodes. The root node is numbere…
Colorful Tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1539    Accepted Submission(s): 616 Sample Input 3 1 2 1 1 2 2 3 6 1 2 1 3 2 1 1 2 1 3 2 4 2 5 3 6 Sample Output Case #1: 6 Case #…
Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2668    Accepted Submission(s): 562 Problem Description Sample Input 1 a 2 aa bb 3 a ba abc Sample Output Case #1: 25 Case #2: 132…
KazaQ's Socks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 338    Accepted Submission(s): 212 Sample Input 3 7 3 6 4 9 Sample Output Case #1: 3 Case #2: 1 Case #3: 2 Source 2017 Multi-Unive…
Add More Zero Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 398    Accepted Submission(s): 283 Sample Input 1 64   Sample Output Case #1: 0 Case #2: 19   Source 2017 Multi-University Trainin…
Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 4124    Accepted Submission(s): 1004 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters.…
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6069 题目: Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1235    Accepted Submission(s): 433 Problem Description In mathem…
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6071 题目: Lazy Running Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 144    Accepted Submission(s): 62 Problem Description In HDU, you have…
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6060 题目: RXD and dividing Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 522    Accepted Submission(s): 219 Problem Description RXD has a tr…
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6058 题目: Kanade's sum Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 505    Accepted Submission(s): 176 Problem Description Give you an array …
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6035 题面: Colorful Tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1651    Accepted Submission(s): 675 Problem Description There is a tre…
学长讲座讲过的,代码也讲过了,然而,当时上课没来听,听代码的时候也一脸o((⊙﹏⊙))o 我的妈呀,语文不好是硬伤,看题意看了好久好久好久(死一死)... 数学+思维题,代码懂了,也能写出来,但是还是有一点不懂,明天继续. 感谢我的队友不嫌弃我是他的猪队友(可能他心里已经骂了无数次我是猪队友了_(:з」∠)_ ) Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Other…
学长好久之前讲的,本来好久好久之前就要写题解的,一直都没写,懒死_(:з」∠)_ Senior Pan Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1332    Accepted Submission(s): 533 Problem Description Senior Pan fails in his discrete ma…
Problem Description There is a youngster known for amateur propositions concerning several mathematical hard problems. Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations…
Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 177    Accepted Submission(s): 74 Problem Description On a two-dimensional plane, give you n integer points. Your task is to figur…
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=6043 [Description] 一个人壁橱里有n双袜子,每天早上取一双最小下标的袜子,然后晚上放到篮子里;当篮子里的袜子个数到达n-1的时候,他会把它们全部洗一遍,然后第二天再把这n-1双放到壁橱里(先取完最后那一只在壁橱里的再把n-1双放进去); [Solution] 可以模拟一下取袜子的序列,比如有4只袜子 1 2 3 4 1 2 3 1 2 4 1 2 3 1 2 4 可以发现; 一开始…