寻找最大值
原题:寻找最大值
原题大意给定N个数A1, A2, A3, … AN,小Ho想从中找到两个数Ai和Aj(i ≠ j)使得乘积Ai × Aj × (Ai AND Aj)最大。其中AND是按位与操作。
算法分析这题时间空间限制不太紧,暴力就可以过,但是可以用高维前缀维护最大值和次大值来做。因为2^20可以枚举的到,而且枚举x&y的结果z,不会丢解,因为z相当于x&y的子集,就是说z是x的子集,z也是y的子集。
http://www.cnblogs.com/forever97/p/hihocoder1496.html
程序代码#include <cstdio>
#include <algorithm>
using namespace std;
int T, n;
//高维前缀的数据结构
struct info
{
int val[2];
info operator + (const info & rhs)const{
int t_val[2] = {val[0], val[1]};
for
...