提交时间:2022-07-19 11:52:48
运行 ID: 52321
#include <bits/stdc++.h> #define ll long long using namespace std; const int mod=1e9+7; ll m,k,n; ll l,r,a,b,c,h; ll rev(ll x){ for(int i=0;2*(i+1)<=k;i++){ bool z=(x&(1LL<<i)); bool w=(x&(1LL<<(k-i-1))); if(z==w) continue; else x^=(1LL<<i),x^=(1LL<<(k-i-1)); }return x; } ll get(ll x){ if(x&1){ return (n-1)^rev((x-1)/2); }else return rev(x/2); } ll F(ll l,ll r){ ll ret=0; if(!(l&1)){ if(r&1){ if(((r-l+1)>>1)%2==0) return 0; else return n-1; }else{ ret=((r-l)>>1)%2==0?0:n-1; ret=ret^get(r); return ret; } }else{ if(r&1){ ret=(r-l)/2*(n-1)+get(l); return ret; }else{ ret=(r-l-1)/2*(n-1)+get(l)+get(r); return ret; } } } int main(){ scanf("%lld",&k); n=(1LL<<k); scanf("%lld%lld%lld",&m,&l,&r); scanf("%lld%lld%lld",&a,&b,&c); int h=0; for(int i=1;i<=m;i++){ h=(l^r^h^F(l,r))%mod+c; if(h>=mod) h=h%mod; l=l^a^h; if(l>=n+1) l=l%(n+1); if(l>=n) l=l-n; r=r^b^h; if(r>=n-l) r=r%(n-l); r=r+l; } printf("%d",h); }