MORE XOR

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
int a[maxn];
int sum[][maxn];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
memset(sum,,sizeof(sum));
for(int i=; i<=n; i++)
cin>>a[i];
for(int i=;i<=n;i++)
{
sum[][i]=sum[][i-];
sum[][i]=sum[][i-];
sum[][i]=sum[][i-];
sum[][i]=sum[][i-];
if(i%==)
sum[][i]^=a[i];
else if(i%==)
sum[][i]^=a[i];
else if(i%==)
sum[][i]^=a[i];
else if(i%==)
sum[][i]^=a[i];
}
int q;
cin>>q;
while(q--)
{
int l,r;
cin>>l>>r;
int len=(r-l+)%;
int ans=;
if(len==)
{
int yu=l;
ans=sum[yu%][r]^sum[yu%][l-];
}
else if(len==)
{
int yu=l;
ans=sum[yu%][r]^sum[yu%][l-]^sum[(yu+)%][r]^sum[(yu+)%][l-];
}
else if(len==)
{
int yu=l;
ans=sum[(yu+)%][r]^sum[(yu+)%][l-];
}
cout<<ans<<"\n";
}
}
}

MORE XOR的更多相关文章

  1. [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...

  2. 二分+DP+Trie HDOJ 5715 XOR 游戏

    题目链接 XOR 游戏 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  3. BZOJ 2115 【Wc2011】 Xor

    Description Input 第一行包含两个整数N和 M, 表示该无向图中点的数目与边的数目. 接下来M 行描述 M 条边,每行三个整数Si,Ti ,Di,表示 Si 与Ti之间存在 一条权值为 ...

  4. xor和gates的专杀脚本

    前段时间的一次样本,需要给出专杀,应急中遇到的是linux中比较常见的两个家族gates和xor. 首先是xor的专杀脚本,xor样本查杀的时候需要注意的是样本的主进程和子进程相互保护(详见之前的xo ...

  5. Codeforces617 E . XOR and Favorite Number(莫队算法)

    XOR and Favorite Number time limit per test: 4 seconds memory limit per test: 256 megabytes input: s ...

  6. Xor && 线性基练习

    #include <cstdio> #include <cstring> ; ; int cnt,Ans,b,x,n; inline int Max(int x,int y) ...

  7. BC之Claris and XOR

    http://acm.hdu.edu.cn/showproblem.php?pid=5661 Claris and XOR Time Limit: 2000/1000 MS (Java/Others) ...

  8. 异或链表(XOR linked list)

    异或链表(Xor Linked List)也是一种链式存储结构,它可以降低空间复杂度达到和双向链表一样目的,任何一个节点可以方便的访问它的前驱节点和后继结点.可以参阅wiki 普通的双向链表 clas ...

  9. hdu 5661 Claris and XOR

    Claris and XOR Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  10. [BZOJ 2819]NIM(dfs序维护树上xor值)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2819 分析: 树上的nim游戏,关键就是要判断树上的一条链的异或值是否为0 这个题目有 ...

随机推荐

  1. Java 多线程 - Synchronized关键字

    目录 1-Synchronized 关键字概述 2- Synchronized关键字作用域 3- Synchronized 原理(反编译指令解释) 正文 1-Synchronized 关键字概述 由于 ...

  2. 【python】面向对象编程之@property、@setter、@getter、@deleter用法

    @property装饰器作用:把一个方法变成属性调用 使用@property可以实现将类方法转换为只读属性,同时可以自定义setter.getter.deleter方法 @property&@ ...

  3. GIt -- fatal: refusing to merge unrelated histories 问题处理

    今晚碰到这个问题-- fatal: refusing to merge unrelated histories 想了一下,为什么就这样了? 因为我是先本地创建了仓库,并添加了文件,然后再到github ...

  4. SecureCRT标签显示IP地址

    当使用SecureCRT连接到linux服务器后,SecureCRT的标签会随着操作目录的改变而改变,当连接多个的时候很不好区分,所以需要设置标签栏固定显示IP地址信息. options->Se ...

  5. swoole 4种PHP回调函数风格

    匿名函数 $server->on('Request', function ($req, $resp) use ($a, $b, $c) { echo "hello world" ...

  6. 通过GIT_COMMIT进行代码回滚

    首先需要安装插件:conditional-buildstep A buildstep wrapping any number of other buildsteps, controlling thei ...

  7. 关于haproxy

    高性能负载均衡软件 haproxy 一.四层和七层负载均衡的区别: 所谓的四层就是OSI参考模型中的第四层,四层负载均衡也称为四层交换机,他主要是通过分析IP层及TCP/UDP层的流量实现的基于IP加 ...

  8. Django By Example 总结

    从3月1号到3月23号总共24天完成了三个项目,时间很赶,学的很充实,但是憋的有点难受了,从下周开始就有上机实验了,抽不出来很多时间学课外的东西了.任务进度拖延了一个星期的进度,主要是因为我懒.... ...

  9. spring boot mybatis打印SQL语句

    在logback-spring.xml 文件中添加 <logger name="com.ibatis" level="DEBUG" /> <l ...

  10. Kubernetes - 腾讯蓝鲸配置平台(CMDB)开源版部署

    蓝鲸CMDB 蓝鲸配置平台(蓝鲸CMDB)是一个基于运维场景设计的企业配置管理服务.主要功能: 1. 拓扑化的主机管理:主机基础属性.主机快照数据.主机归属关系管理 2. 组织架构管理:可扩展的基于业 ...