CF1322B Present

Jinnie

看到莫名其妙的异或题,应该考虑按照位数处理。

这样我们分别考虑每一位的答案,需要先取模。

排序,让序列有了单调性,并且可以观察到,对于第k位只有两个数的和属于

$[2^k,2^{k+1}-1]cap[2^{k+1}+2^k,2^{k+2}-2]$才行

最后的右边界是什么东西?我们取模了啊.
双指针解决。

#include<cstdio>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cmath>
#include<stack>
#include<algorithm>
#define int long long
using namespace std;
template<class T>inline void read(T &x)
{
    x=0;register char c=getchar();register bool f=0;
    while(!isdigit(c))f^=c=='-',c=getchar();
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    if(f)x=-x;
}
template<class T>inline void print(T x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar('0'+x%10);
}
int n;
int ans;
int a[400005];
int b[400005];
int cal(int L,int R){
    if(L>R) return 0;
    int res=0;
    int l=1;
    int r=1;
    for(int i=n;i>=1;--i){
        while(l<=n&&b[i]+b[l]<L) ++l;
        while(r<=n&&b[i]+b[r]<=R) ++r;
        res+=r-l-(l<=i&&r>i);
    }
    return (res>>1)&1;
}
int deal(int x){
    for(int i=1;i<=n;++i){
        b[i]=(a[i]&((1<<(x+1))-1));
    }
    sort(b+1,b+n+1);
    return cal(1<<x,(1<<(x+1))-1)^cal(3<<x,(1<<(x+2))-2);
}
signed main(){
    read(n);
    for(int i=1;i<=n;++i){
        read(a[i]);
    }
    for(int i=0;i<26;++i){
        ans|=deal(i)<<i;
    }
    cout<<ans;
    return 0;
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇