zcmimi's blog
avatar
zc
2019-12-21 19:47:00
  • 本文总阅读量
查看原题

点击跳转

i对答案会统计\left \lfloor \frac ni \right \rfloor次,但只有出现奇数次才会产生贡献

每次的贡献是i \bigoplus i+1 \bigoplus ... \bigoplus j,那么可以用数列之异或这道题的思路做

#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
#define N 10001
ll n,ans=0;
ll get(ll x){
    int t=x%4;
    if(!t)return x;
    if(t==1)return 1;
    if(t==2)return x+1;
    return 0;
}
int main(){
    cin>>n;
    for(ll i=1,j;i<=n;i=j+1){
        j=n/(n/i);
        if((n/i)&1)ans^=get(j)^get(i-1);
    }
    cout<<ans<<endl;
}
51nod 1984 异或约数和
comment评论
Search
search