提交时间:2022-08-09 11:34:13

运行 ID: 55137

#include <bits/stdc++.h> using namespace std; template<typename T> inline void red(T &x) { bool s=1;x=0;char c=getchar(); while(c<=32) c=getchar(); if(c=='-') s=-1,c=getchar(); for(; ('0'<=c && c<='9'); c=getchar()) x=(x<<3)+(x<<1)+(c^48); x=(s==1?x:-x); } unsigned int SA, SB, SC;int p, A, B; int n,k,m,a[10000001],b[10000001]; unsigned int rng61(){ SA ^= SA << 16; SA ^= SA >> 5; SA ^= SA << 1; unsigned int t = SA; SA = SB; SB = SC; SC ^= t ^ SA; return SC; } int T; void gen(){ scanf("%d%d%d%d%u%u%u%d%d", &n, &k, &m,&p, &SA, &SB, &SC, &A, &B); for(int i = 1; i <= p; i++)scanf("%d%d", &a[i], &b[i]); for(int i = p + 1; i <= n; i++){ a[i] = rng61() % A + 1; b[i] = rng61() % B + 1; } } bool check(int x) { int ans=0; for(int i=x; i; i>>=1) ans+=a[i]; return ans&1; } void sbt1() { int ans=0; for(int i=n; i>=1; i--) if(check(i)) ans+=b[i]; cout<<ans<<endl; return ; } int main() { scanf("%d",&T); while(T--) { gen(); if(m==2) sbt1(); } return 0; }