提交时间:2022-07-19 11:51:37
运行 ID: 52281
#include<cstdio> #include<algorithm> #include<ctype.h> #include<cstring> #include<iostream> #include<vector> #include<queue> #include<ctime> #include<cmath> #include<queue> #include<map> #include<set> #include<unordered_map> #include<stack> #define pr pair<int,int> #define eps 1e-8 #define db double #define int long long using namespace std; inline int read() { int x=0,f=1; char ch=getchar(); while(!isdigit(ch)) { if(ch=='-')f=-1; ch=getchar(); } while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar(); } return x*f; } const int Mod=1e9+7; int n,k,m; vector<int>awa[2005]; int val[2005]; void FFT(int cur) { if(cur==0) return; for(int i=0; i<(1<<(cur-1)); i++) { int qwq=(1<<cur)-i-1; reverse(awa[qwq].begin(),awa[qwq].end()); for(auto v:awa[qwq]) awa[i].push_back(v); } FFT(cur-1); } int a,b,c,now; int query(int l,int r) { vector<int>ret; for(int i=l; i<=r; i++) ret.push_back(val[i]); if(l&1) { int ans=0; for(int i=1; i<(int)ret.size(); i+=2) if(i+1<(int)ret.size()) ret[i]=ret[i]^ret[i+1]; ans=ret[0]; for(int i=1; i<(int)ret.size(); i+=2) ans=ans+ret[i]; return ans; } else { int ans=0; for(int i=0; i<(int)ret.size(); i+=2) if(i+1<(int)ret.size()) ret[i]=ret[i]+ret[i+1]; for(int i=0; i<(int)ret.size(); i+=2) ans=ans^ret[i]; return ans; } } int h,l,r; signed main() { k=read(); n=(1<<k); m=read(),l=read(),r=read(); a=read(),b=read(),c=read(); for(int i=0; i<(1<<k); i++) awa[i].push_back(i); FFT(k); for(int i=0; i<(1<<k); i++) val[i]=awa[0][i]; for(int i=1; i<=m; i++) { h=((l^r^h^query(l,r))+c)%Mod; l=((l^a^h)%(n+1))%n; r=((r^b^h)%(n-l))+l; } printf("%lld\n",h); return 0; }