Problem Description Memphis loves xor very musch.Now he gets an array A.The length of A is n.Now he wants to know the sum of all (lowbit(Ai xor Aj) (i,j∈[1,n]) We define that lowbit(x)=2^k,k is the smallest integer satisfied ((x and 2^k)>0)Specially,…
Description Pog and Szh are playing games.There is a sequence with $n$ numbers, Pog will choose a number A from the sequence. Szh will choose an another number named B from the rest in the sequence. Then the score will be $(A+B)$ mod $p$.They hope to…
题目电波: HDU--5269 ZYB loves Xor I 首先我们先解决 ai xor aj 每个数转化为二进制  我们用字典树统计 每个节点 0 和 1 的出现的个数 #include<bits/stdc++.h> using namespace std; #define maxn 50000 #define mod 998244353; struct ac{ ]; void init(){ sum=; memset(nex,,sizeof(nex)); } }tre[maxn*];…
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=275 这是一道xor高斯消元. 题目大意是给了n个数,然后任取几个数,让他们xor和最大. 首先根据题目意思可以列出下列方程组: //a11x1+a21x2……=d[1] //a12x1+a22x2……=d[2] //... (每个数二进制按列来写,xi为0或1,表示取或不取这个数.) 结果的二进制即为d数组. 由于需要结果最大,而结果最多是d全为1,那么就假设所有d均为1,然后进行高斯消…
分治法和字典树都可以,都是递归,但字典树耗内存 从第一bit开始,若相同则xor为0,分到同一部分,不相同则统计,且此时lowbit为这一bit,最后结果要乘以2 /*分治法*/ #include<cstdio> #define MOD 998244353 using namespace std; ],t[],T,cas=,n,sum; void fenzhi(int l,int r,int mask) { ||mask==<<) return; ; for(i=l;i<r;…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5592 题目大意就是给了每个[1, i]区间逆序对的个数,要求复原原序列. 比赛的时候2B了一发. 首先既然给了[1, i-1]和[1, i]区间逆序对的个数,自然可以求出与i组成逆序对的个数,自然就是i前面比i大的个数,自然也就能求出i前面比i小的个数. 然后我考虑最后一个数,由于它在最后一个,所以所有数都在它前面,自然如果知道它前面有多少个比他小的,就知道它是几了.不妨设最后一个是p,然后考虑倒数…
http://acm.hdu.edu.cn/showproblem.php?pid=5700 这是这次百度之星初赛2B的第五题.省赛回来看了一下,有这样一个思路:对于所有的区间排序,按左值排序. 然后枚举区间左值lt,计算区间右值rt最大是多少,并且满足与至少k个区间相交.关键是解决与k个区间相交这个关系.首先区间左值大于lt的是不考虑的,因为这样相交区间的左值就不是lt了.也就是考虑区间左值小于等于lt的区间中,与rt区间至少有k个相交的区间.也就是在前面的条件下,计算是否有至少k个区间右值大…
Problem Description One day, a useless calculator was being built by Kuros. Let's assume that number X is showed on the screen of calculator. At first, X = 1. This calculator only supports two types of operation. 1. multiply X with a number. 2. divid…
Sample Input 9 5 6 7 8 113 1205 199312 199401 201314 Sample Output Case #1: 5 Case #2: 16 Case #3: 88 Case #4: 352 Case #5: 318505405 Case #6: 391786781 Case #7: 133875314 Case #8: 83347132 Case #9: 16520782 题目要求当前字符串序列中某项里cff前缀两两间差值的和. 假设已经纪录了cff前缀的…
DescriptionDoctor Ghee is teaching Kia how to calculate the sum of two integers. But Kia is so careless and alway forget to carry a number when the sum of two digits exceeds 9. For example, when she calculates 4567+5789, she will get 9246, and for 12…