BZOJ4245 ONTAK2015 OR-XOR Description 给定一个长度为n的序列a[1],a[2],…,a[n],请将它划分为m段连续的区间,设第i段的费用c[i]为该段内所有数字的异或和,则总费用为c[1] or c[2] or … or c[m].请求出总费用的最小值. Input 第一行包含两个正整数n,m(1<=m<=n<=500000),分别表示序列的长度和需要划分的段数. 第一行包含n个整数,其中第i个数为a[i](0<=a[i]<=1018).…
题目大意:给定 N 个操作,每个操作为按位与.或.异或一个固定的数字,现在要求从 0 到 M 中任选一个数字,使得依次经过 N 个操作后的值最大. 题解:位运算有一个重要的性质是:位运算时,无进位产生,每一位之间相互独立.因此,可以从高到低依次考虑每一位对答案的贡献值,计算每一位经过这 N 个操作后的值,比较后更新答案贡献即可. 代码如下 #include <bits/stdc++.h> using namespace std; const int maxn=1e5+10; int n,m;…
题目链接: zxa and xor Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description zxa had a great interest in exclusive disjunction(i.e. XOR) recently, therefore he took out a non-negative integer sequence …