Advertising
- Anonymous
- Tuesday, March 25th, 2008 at 12:52:12pm MDT
- #include<stdio.h>
- #include<stdlib.h>
- #include<unistd.h>
- #include<signal.h>
- #include<sys/wait.h>
- uc S=1,cr=0, W; ul sk [1024],d,tr; int sp=0,sp1=~0, sp2=~1; pid_t
- p,t; void ss (){ w(S!=W){ kill(t,S1); S=((S<<1)&0xff?S<<1:1); pa(
- ); } kill(t,S2); pa(); } ul AD(ul a,ul b){ do{ a^=b; b=((b^a) &b)
- <<1; }w(b); return a; }ul SU(ul a,ul b){ return AD(a,AD(~b,1)); }
- ul MU (ul a
- ,ul b ){ ul
- e,g,f ,c; e
- =a; g =0; w
- (b>1) { c=2
- ; f=a << 1;
- w(c<b >>1){
- c<<=1 ;f<<=
- 1;} g =AD(f
- ,g); b=SU(b,c); } a=g; if(b){a=AD(a,e); } return a; } ul DI( ul a
- ,ul b){ ul t,u=0;w(MU(u,b)<a){ t=1; w(MU(AD(t<<1,u),b)<a){t<<= 1;
- } u=AD(u,t);} if(MU(u,b)>a){ u=AD(u,~0);} return u;}void SC(int i
- ){S=((S<<1)&0xff?(S<<1)&0xff:1);sg(i,&SC);kill(p,S1);}void DS(int
- i){ cr=0; switch(S){ case 1:sk[sp]|=d;case 2:d<<=1;if(!d){sp2=sp1
- ; sp1=sp ; sp=AD(
- sp,1);sk [sp] =0;
- } break; case 4 : case 8 : case 16: case 32: cr=S;d=0
- ; break; case 64: if (sp > 0 ){ sp2 =SU (sp2 ,1); sp1
- =SU (sp1 ,1); sp= SU(sp,1) ; } else { sp =0; sp1= ~0;
- sp2 =~1; } sk [sp
- ]=0; d=0 ; break; case 128 : if( sp >1) {sk[ sp1]^=sk[
- sp2];sk[ sp2]^=sk [sp1];sk [sp1] ^= sk [ sp2 ]; } d=0
- ; break; } sg (i, &DS); if (d)kill( p,S1); } void Sync
- ( int i) { sg(i,&
- Sync); } void main (void) { p=getpid ( ); sg( S1,&Sync
- );if((t= fork())) { char a [80];pa( );w(1){W =2;scanf
- ("%s",a) ; switch (a[0]) { case 83: W <<= 1; case 68:
- W <<= 1; case 43:
- W <<= 1; case 45: W <<= 1; case 47: W <<= 1; case 42:
- W <<= 1; break ; case 81: kill(t,9 );exit(0 );break;
- default : W=0; tr= atoi(a); break; } if(W)ss( ); else{
- d=1; w(d ){ W=tr&
- d?1:2; d <<=1; ss (); } }} wait(0); }else{ul j;sg(S1,
- &SC); sg (S2,&DS) ; kill(p ,S1); w( 1){ w(d) pa(); d=
- 1; if(cr &&sp >1) {switch( cr){case 4:sk[sp2 ]=MU(sk[
- sp2 ],sk [sp1] );
- break; case 8:sk[sp2]=DI(sk[sp2],sk[sp1]); break; case 16:sk[sp2]
- =SU(sk[sp2],sk[sp1]); break; case 32:sk[sp2]=AD(sk[sp2],sk[sp1]);
- break; } sp=sp1; sp1=sp2; sp2=SU(sp2,1); sk[sp]=0; }pr("====\n");
- for(j=0; j<sp; ){ pr("%lu\n",sk[j]); j=AD(j,1); }kill(p,S1); } }}
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.