1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| #include<bits/stdc++.h> #define re register typedef long long ll; template<class T> inline void read(T &x) { x=0; char ch=getchar(),t=0; while(ch<'0'||ch>'9') t|=ch=='-',ch=getchar(); while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); if(t) x=-x; } template<class T,class ...T1> inline void read(T &x,T1 &...x1){ read(x),read(x1...); } template<class T> inline void write(T x) { if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } template<> inline void write(bool x){ putchar(x?'1':'0'); } template<> inline void write(char c){ putchar(c); } template<> inline void write(char *s){ while(*s!='\0') putchar(*s++); } template<> inline void write(const char *s){ while(*s!='\0') putchar(*s++); } template<class T,class ...T1> inline void write(T x,T1 ...x1){ write(x),write(x1...); } template<class T> inline bool checkMax(T &x,T y){ return x<y?x=y,1:0; } template<class T> inline bool checkMin(T &x,T y){ return x>y?x=y,1:0; } const int N=3e7+10; typedef unsigned long long ull; using int128=__int128_t; int n,A,B,C,u[N],v[N],w[N]; inline ull rnd(ull &k1,ull &k2) { ull k3=k1,k4=k2; k1=k4;k3^=(k3<<23); k2=k3^k4^(k3>>17)^(k4>>26); return k2+k4; } inline void getData() { ull x,y; read(n,A,B,C,x,y); for(int i=1;i<=n;++i) { u[i]=rnd(x,y)%A+1; v[i]=rnd(x,y)%B+1; w[i]=rnd(x,y)%C+1; if(rnd(x,y)%3==0) u[i]=A; if(rnd(x,y)%3==0) v[i]=B; if((u[i]!=A)&&(v[i]!=B)) w[i]=C; } } int Mx[N]; int main() { getData(); int maxW=0; for(int i=1;i<=n;++i) if(u[i]==A&&v[i]==B) checkMax(maxW,w[i]); int128 ans=(int128)A*B*maxW; for(int h=C;h>maxW;--h) { for(int i=1;i<=n;++i) if(w[i]==h) checkMax(Mx[u[i]],v[i]); for(int i=A;i>=1;--i) checkMax(Mx[i],Mx[i+1]); for(int i=1;i<=A;++i) ans+=Mx[i]; } write(ans); return 0; }
|