提交时间:2022-07-19 12:38:08

运行 ID: 52526

#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) { if(l&1) { int tmp=r-l; int res=P*(tmp>>1); if(tmp&1) res+=A(r,k); return res+A(l,k); }else { int tmp=r-l+1; int res=(tmp&2)? P:0; tmp&=1; switch(tmp) { case 0: return res; case 1: return res^A(r,k); default: return 0; } } return 0; } 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; }