博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LibreOJ #113. 最大异或和
阅读量:4353 次
发布时间:2019-06-07

本文共 1806 字,大约阅读时间需要 6 分钟。

二次联通门 : 

 

 

 

/*    LibreOJ #113. 最大异或和        线性基         插入 与 查询最大值        说一下我在学习线性基时遇到的一些问题        1.线性基指的是一个数集    2.。。。没了。        一开始反复看了好几遍,不知道线性基是个什么东西    后来突然明白是个数集而不是个操作什么的。。         突然不能用printf了。。。用printf输出就是负数。。    只能用cout了。。 */#include 
#include
#include
inline void read (long long &now){ register char word = getchar (); bool temp = false; for (now = 0; word < '0' || word > '9'; word = getchar ()) if (word == '-') temp = true; for (; word >= '0' && word <= '9'; now = now * 10 + word - '0', word = getchar ()); if (temp) now = -now;}class Linear_Base_Type{ static const int _L = 62; private : long long number[_L | 1]; public : inline bool Insert (register long long key) { for (register int i = _L; i >= 0; i --) if (key & (1LL << i)) { if (!number[i]) { number[i] = key; break; } key ^= number[i]; } return key > 0; } long long Query_Maxn () { long long res = 0; for (register int i = _L; i >= 0; i --) res = ((res ^ number[i]) > res) ? (res ^ number[i]) : res; return res; }};Linear_Base_Type Make;int main (int argc, char *argv[]){ long long N; read (N); long long x; for (register int i = 1; i <= N; i ++) { read (x); Make.Insert (x); } std :: ios :: sync_with_stdio (false); std :: cout << Make.Query_Maxn (); return 0;}

 

转载于:https://www.cnblogs.com/ZlycerQan/p/7223559.html

你可能感兴趣的文章
[CF487E] Tourists
查看>>
vi 编辑器的用法(2013最新整理)
查看>>
HTML中的footer置底问题
查看>>
[Hei.Captcha] Asp.Net Core 跨平台图形验证码实现
查看>>
truncate与delete的区别
查看>>
wepy 小程序开发(interceptor拦截器 && WXS)
查看>>
Mac下安装virtualenv, 并在PyCharm中使用
查看>>
【poj1010】 STAMPS
查看>>
NOI2015 寿司晚宴
查看>>
取石头游戏
查看>>
2-Nineteenth Scrum Meeting-20151219
查看>>
C 语言实例 - 计算两个时间段的差值
查看>>
Vue去掉警告 You are running Vue in development mode
查看>>
梦织未来Windows驱动编程 第06课 驱动对磁盘文件的操作
查看>>
(剑指Offer)面试题24:二叉搜索树的后序遍历序列
查看>>
vcastr3.swf免费开源android可用的FLV播放器使用详解
查看>>
关情纸尾-----UIKit基础-UITableView
查看>>
python之反射
查看>>
公共类
查看>>
linux系统常用命令
查看>>