hdu 6059 Kanade's trio】的更多相关文章

思路来自题解(看着题解和标程瞎吉尔比划了半天) /* HDU 6059 - Kanade's trio [ 字典树 ]  |  2017 Multi-University Training Contest 3 题意: 给出数组 a[N],问满足 (i<j<k) && ((A[i] xor A[j])<(A[j] xor A[k])) 的三元组数数量 限制 N<=5e5, a[i] <= 2^30 分析: 对于某一对 ai, ak ,满足条件的 aj 为: 对于…
Kanade's trio Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 960    Accepted Submission(s): 361 Problem Description Give you an array A[1..n],you need to calculate how many tuples (i,j,k) sat…
题 OwO http://acm.hdu.edu.cn/showproblem.php?pid=6059 解 由于每个数字最多是30位,枚举数字每一位考虑, 建一棵记录前缀(位的前缀,比如10拆成1010,那么就把1010从前往后插入这个字典树中)的字典树, nxt记录其后继,gcnt记录这个节点添加的个数,ng代表不符合要减去的个数(后文会提到) tol[i][j]代表第i位的j(j=0,1)当前数量 枚举Ak的每一位,对于Ak的第t位(记作Ak[t]) 1. 如果Ak[t]==1,那么对答案…
转自:http://blog.csdn.net/dormousenone/article/details/76570172 /** 题目:hdu6059 Kanade's trio 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6059 题意:含 N 个数字的 A 数组,求有多少个三元组 (i,j,k) 满足 i<j<k 且 (Ai⊕Aj)<(Aj⊕Ak) 思路: 利用字典树维护前 k-1 个数.当前处理第 k 个数. 显然对于 k 与 i 的…
/* HDU 6057 - Kanade's convolution [ FWT ] | 2017 Multi-University Training Contest 3 题意: 给定两个序列 A[0...2^m-1], B[0...2^m-1] 求 C[0...2^m-1] ,满足: C[k] = ∑[i&j==k] A[i^j] * B[i|j] m <= 19 分析: 看C[k]的形式与集合卷积的形式接近,故转化式子时主要向普通的集合卷积式方向靠 与三种位运算都相关的结论是 : i^j…
/* HDU 6058 - Kanade's sum [ 思维,链表 ] | 2017 Multi-University Training Contest 3 题意: 给出排列 a[N],求所有区间的第k大数之和 N <= 5e5, k <= 80 分析: 先求出每个数的位置pos[]数组 然后维护一个单调链表,按数字从大到小向里面加该数字的位置 即对于i的位置 pos[i] 找到链表中比它大的第一个位置和比它小的第一个位置,将pos[i]加到两个之间 这部分用set实现,复杂度 O(nlog…
Problem Description Give you an array A[1..n],you need to calculate how many tuples (i,j,k) satisfy that (i<j<k) and ((A[i] xor A[j])<(A[j] xor A[k])) There are T test cases. 1≤T≤20 1≤∑n≤5∗105 0≤A[i]<230   Input There is only one integer T on…
Kanade's sum Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2723    Accepted Submission(s): 1132 Problem Description Give you an array A[1..n]of length n. Let f(l,r,k) be the k-th largest eleme…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6057 [题目大意] 有 C[k]=∑_(i&j=k)A[i^j]*B[i|j] 求 Ans=∑ C[i]*1526^i%998244353 [题解] 将C[k]代入Ans的计算式得到 Ans=∑ A[i^j]*B[i|j]*1526^(i&j)%MOD 我们发现(i^j)&(i&j)=0且(i^j)^(i&j)=i|j, 因此bit[i^j]+bit[i&j…
Kanade's sum Problem Description Give you an array A[1..n]of length n. Let f(l,r,k) be the k-th largest element of A[l..r]. Specially , f(l,r,k)=0 if r−l+1<k. Give you k , you need to calculate ∑nl=1∑nr=lf(l,r,k) There are T test cases. 1≤T≤10 k≤min(…