CF1109A Sasha and a Bit of Relax】的更多相关文章

CF1109A Sasha and a Bit of Relax 用 \(xorsum[l,r]\) 表示 \(a[l] \oplus a[l+1] \oplus a[l+2]... a[r-1] \oplus a[r]\). 则数对 \((l,r)\) 满足 \(xorsum[l,mid]=xorsum[mid+1,r]\ and\ 2|(r-l).\)而 \[ xorsum[l,mid]=xorsum[mid+1,r]\\ \Leftrightarrow xorsum[l,r]=0\\ \L…
Problem   Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax Time Limit: 2000 mSec Problem Description Input The first line contains one integer n (2≤n≤3⋅10^5) — the size of the array. The second line contains n integers a1,a2,…,an (0≤ai<2^…
Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve unsolved…
time limit per test: 1 secondmemory limit per test: 256 megabytesinput: standard inputoutput: standard output Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since S…
题中意思显而易见,即求满足al⊕al+1⊕…⊕amid=amid+1⊕amid+2⊕…⊕ar且l到r的区间长为偶数的这样的数对(l,r)的个数. 若al⊕al+1⊕…⊕amid=amid+1⊕amid+2⊕…⊕ar,我们可以推出al⊕al+1⊕…⊕amiamid+1⊕amid+2⊕…⊕ar=0:反推也是可以成立的. 我们已知任何数0对异或都等于本身.所以当前数异或一段数之后等于本身,那么异或之后的这段数肯定是异或为0的,我们只需要知道这一段是不是长度为偶数即可. 我们从头异或一道,若异或到某个数…
关于异或运算,是可以求前缀和的.还有一些异或运算的性质 0^a=a; 交换律 a^b=b^a 结合律 a^(b^c)=(a^b)^c 分配率 a^(b+c)=a^b+a^c 自反律 a^b^b=a 判断两个数是否相等 a^b=0 这个题真的学到好多 要找 al⊕al+1⊕…⊕amid=amid+1⊕amid+2⊕…⊕ar,即 0=al⊕al+1⊕…⊕amid⊕amid+1⊕amid+2⊕…⊕ar: 然后用一个sum数组保留前缀异或. 对于要求r-l+1是偶数,那么l,r一定不同奇偶. 只要找(l…
转载自:https://blog.csdn.net/Charles_Zaqdt/article/details/87522917 题目链接:https://codeforces.com/contest/1113/problem/C        题意是给了n个数字,让找出一个长度为偶数的区间[l, r],使得al ^ al+1 ^ .... ^ amid = amid + 1 ^ ... ^ ar这个等式成立(l到mid的异或和等于mid+1到r的异或和),求出有多少个满足要求的区间.    …
Codeforces Round #539 Div1 题解 听说这场很适合上分QwQ 然而太晚了QaQ A. Sasha and a Bit of Relax 翻译 有一个长度为\(n\)的数组,问有多少个长度为偶数的连续区间,使得其前一半的异或和等于后一半的异或和. 题解 显然就是求长度为偶数且异或和为\(0\)的区间个数 求异或和为\(0\)的区间个数很简单,对于整个区间求异或前缀和看看有多少个相等就好了. 求长度为偶数的也很简单,把每个位置的异或前缀和按照位置的奇偶性分开求个数每次计算一下…
Codeforces Round #539 (Div. 2) A - Sasha and His Trip #include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #incl…
Codeforces Round #539 (Div. 1) A. Sasha and a Bit of Relax description 给一个序列\(a_i\),求有多少长度为偶数的区间\([l,r]\)满足\([l,mid]\)的异或和等于\([mid+1,r]\)的异或和. solution 等价于询问有多少长度为偶数的区间异或和为\(0\). 只需要两个位置的异或前缀和与下标奇偶性相同即可组成一个合法区间. #include<cstdio> #include<algorith…