提交时间:2022-07-19 12:09:32
运行 ID: 52418
#include <cstdio> #define FILEIO #ifdef FILEIO FILE *infile=fopen("fold.in","r"), *outfile=fopen("fold.out","w"); #define scanf(x...) fscanf(infile,x) #define printf(x...) fprintf(outfile,x) #endif // FILEIO int k,m,l,r,a,b,c,h; int P,n; const int mod=1000000007; inline int A(int i,const int K) { if(!K) return 0; if(i&1 and k==K) return A(i>>1,K-1)^((1<<K)-1); if(i&1) return A(i>>1,K-1)^(1<<K); return A(i>>1,K-1); } inline int F(int l,int r) { int res=0; for(int i=(r>>2<<2)+1;i<=r and i>=l;++i) res^=A(i,k); if(l&1) { for(int i=l+1;i&3;++i) res^=A(i,k); res+=A(l,k); }else { for(int i=l+2;(i&3)!=1;++i) res^=A(i,k); res^=A(l,k)+A(l+1,k); } return res; } int main() { scanf("%d%d%d%d%d%d%d",&k,&m,&l,&r,&a,&b,&c); P=(1<<k)-1; n=1<<k; for(int i=1;i<=m;++i) { h=(l^r^h^F(l,r)); h+=c-mod; h+=((h>>31)&mod); l=l^a^h; l%=n|1; l&=P; r=(r^b^h)%(n-l); r+=l; } printf("%d\n",h); #ifdef FILEIO fclose(infile); fclose(outfile); #undef scanf #undef printf #endif // FILEIO return 0; }