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
| #include<bits/stdc++.h> #define pbk emplace_back #define FOR(i,a,b) for(int i=a,i##i=b;i<=i##i;++i) using namespace std; typedef unsigned long long ull; const int N=407; ull a[N],C=400,L=9; void NOT(int x,int y){printf("NOT %d %d\n",x,y),a[x]=~a[y];} void LSH(int x,int y){printf("LSH %d %d\n",x,y),a[x]<<=y;} void RSH(int x,int y){printf("RSH %d %d\n",x,y),a[x]>>=y;} void SET(int x,int y){printf("SET %d %d\n",x,y),a[x]=a[y];} void XOR(int x,int y,int z){printf("XOR %d %d %d\n",x,y,z),a[x]=a[y]^a[z];} void AND(int x,int y,int z){printf("AND %d %d %d\n",x,y,z),a[x]=a[y]&a[z];} void OR(int x,int y,int z){printf("OR %d %d %d\n",x,y,z),a[x]=a[y]|a[z];} int b[N],A[N],B[N],And[N],Or[N],s0[N],sif[N]; void solve(int l,int r){ int mid=(l+r)/2; if(l==r){ AND(s0[l],Or[l],s0[l]),OR(s0[l],s0[l],And[l]); AND(sif[l],Or[l],sif[l]),OR(sif[l],sif[l],And[l]); return; } solve(l,mid),solve(mid+1,r); FOR(i,mid+1,r){ AND(4,s0[mid],s0[i]); AND(5,sif[mid],s0[i]); OR(s0[i],4,sif[i]); OR(sif[i],sif[i],5); } } void build(int l,int r){ if(l==r){ SET(A[l],sif[l]); if(l!=63)LSH(A[l],l+1); else A[l]=++L; return; } int mid=(l+r)/2; build(l,mid),build(mid+1,r); OR(A[l],A[l],A[mid+1]); } int main(){ freopen("dt.in","r",stdin); freopen("cal2.out","w",stdout); cin>>a[1]>>a[2]; cerr<<a[1]+a[2]<<endl; XOR(3,1,2),NOT(400,400),RSH(400,63); FOR(i,0,63)b[i]=--C,SET(C,400),LSH(b[i],i); FOR(i,0,63)A[i]=++L,AND(L,1,b[i]),RSH(L,i); FOR(i,0,63)B[i]=++L,AND(L,2,b[i]),RSH(L,i); FOR(i,0,63)And[i]=++L,AND(L,A[i],B[i]); FOR(i,0,63){ Or[i]=B[i],OR(Or[i],A[i],B[i]); sif[i]=++L,s0[i]=A[i],SET(s0[i],400); } solve(0,63),build(0,63); XOR(1,3,A[0]); cerr<<a[1]; return 0; }
|