2012年4月9日星期一

Moncler Sale03 2012 freedom

Title: E problem ,given a two Boolean expressions ,there are ( !, & ;,, ) operations in four ( according to the priority from high to low ) ,and ( ) ,with up to 15 variables,check two expressions are equivalent .
Since only a maximum of 15 variables,then the enumeration value of each variable and then examines two expression of the results are the same as you can .!The A operation can process ( A ) ,then the suffix expression into an infix expression to ( code in data structure operations on the change is made, level of confusion ,template for production) .
Code :# include< ;stdio.h> ;memory.h> ;# # include< ;include< ;iostream> ;map> ;# # include< ;include< ;cstring> ;using namespace STD ;map< ;string ,int> ;name ;int n ,total ,wokao ,f ;struct Node type { int ,x ,y ;char OP ;void Print ( ) {if ( type = = 0 )printf ( %c ,OP ) ;else printf ( %d ,x ) ;} } Zero ;bool operator< ;( Node a ,Node b ) / / Overloaded Operators {if ( a.
op = = return false if ;) ;( a.op = = ) {if ( b.op = = ;return true ;return false ) ;} if ( b.op = = ) return false ;return true ;} / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Satck * * * * * * * * * * * * * * * * * * * * * * * * * * * / class Stack / / class stack {private: Node list ;/ / stack int top ;/ / stack toppublic: Stack ( ) ;/ / constructed function void Clear ( ) ;/ / initialize stack void Pop ( ) ;/ / Pop int Size ( ) ;/ / return the size of the stack void Push ( Node T ) ;/ / push an element to stack Node Top ( ) ;/ / return the top element of the stack bool Empty ( ) ;/ / return if the stack is empty} ;Stack: :Stack ( ) {memset ( Li St ,0,sizeof ( list ) ) ;top = 0 ;} void Stack: :Clear ( ) {top = 0 ;} void Stack: :Pop ( ) {top :int ;} Stack :: Size ( ) {return top ;} void Stack: :Push ( Node T ) {list top + + = t ;} Node Stack: :Top ( ) {return list ;} bool Stack: :Empty ( ) {return top = = 0 ;} / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Expression * * * * * * * * * * * * * * * * * * * * * * * * * / class Expression {private: char exp ;/ / infix expression Stack sta ;/ / stack Node ans ;/ / postfix expression int num element number of ;/ / the postfix expressionpublic: Expression ( ) ;/ / constructed function int Error ( int k ) ;/ / error processing bool Input ( ) ;/ / input int Deal ( Node T ) ;/ / solve a single node int Solve ( ) ;/ / tranfer infix expression to postfix expression int Calc ( ) ;/ / calculate the answer of the postfix expression void Clear ( ) ;/ / initialize the Expression void BiliBili ( ) ;int Operate ( int a ,char b ,int c ) ;} ;Expression: :Expression ( ) {num = 0 ;} void Expression: :Clear ( ) {sta.
Clear ( ) ;num = 0 ;} bool Expression: :Input ( ) {char TMP ;strcpy ( TMP , 0) ;gets ( TMP ) ;int Bi = 0 [url=http://www.style-jackets.com/]Moncler Sale[/url]

http://www.style-jackets.com/

,I = 0 ;while ( TMP != 0) {if ( TMP = = = = = = = = = = = = ) {I + + ;continue ;} TMP Bi + = TMP i + + ;} TMP = 0;int len = strlen ( TMP ) ;if ( len = = 0 )return false ;int k = 0 ;bool flag = true ;while ( flag ) {len = strlen ( TMP ) ;flag = false ;k = 0 ;for ( I = 0 ;i< ;len ;I + + ) if ( TMP = = = = = = = = = = = = ! ) {flag = true ;exp K + = ;exp ( + = .
;I + + ;if ( ( TMP > ;= ;& ;TMP i = < ; ( TMP ) = > ;& ;& ;TMP < ; ) ) {for ( len& ;& ;i< ;TMP ;( ( > ;= ;& ;TMP i = < ; ( TMP ) = > ;& ;& ;TMP < ; ) ) ;I + + ) exp K + = TMP ;exp K + = ) ;I ;} else {int Ba = 0 ;( for ;i< ;len ;I + + ) if ( TMP i = = = = = = = = = = = = ( ) {Ba + + ;exp K + = ( ;} else if ( TMP = = = = = = = = = = = = ) ) {Ba :exp ; + = ) ;if ( BA = = 0 ){exp K + = ) ;break ;} } else exp K + = TMP ;} } else if ( TMP != ) exp K + = TMP ;exp k = 0;strcpy ( TMP ,exp ) ;} Clear ( ) ;return true ;} int Expression: :Deal ( Node T ) {if ( T.
TYPE = = 1 )ans num + = t if ;else ( t.op = = ( ) sta.Push ( T ) ;/ / if it is ( push it to stack else ,if ( t.op = = = = = = = ) ) {while ( !Sta.Empty ( ) ) / / put all the element in the stack before ( {Node TMP = sta.
Top ( ) ;sta.Pop ( ) ;if ( tmp.op = = ( ) return 0 ;ans num + = TMP ;} return / 1;/ if there is no ( this expression is wrong ,} else {while ( !Sta.Empty ( ) & ;& ;sta.
Top ( ) . Op ( & != ;& ;( sta.Top ( < !) ;t ) ) {ans num + = sta.Top ( ) ;sta.Pop ( ) ;} sta.Push ( T ) ;/ / push it to stack} return 0 ;} int Expression: :Solve ( ) {int i = 0 ,k = 0 ,flag = 1 ,len ;Node TMP ;len = strlen ( EXP ) ;while ( i< ;len ) {if ( Exp = = = = = = = = = = = = ( = = = = = = = = = = = = ) ) {tmp.
op = exp ;tmp.type = 0 ;Deal ( TMP ;I + + ) ;} else if ( ( Exp = > ;& ;& ;exp < ; ( EXP ) = > ; ;& ;exp < ; ) ) {string s ;s.
clear ( ) ;tmp.x = 0 ;tmp.type = 1 ;for ;( ( ( Exp = > ;& ;& ;exp < ; ( ) exp = > ;& ;& ;exp < = ) ) ;& ;& ;i< ;len ;I + + ) s + = exp i ;if ( name = = 0 )name S = + + n ;tmp.
x = name ;Deal ( TMP ) ;flag = 0 ;} else {if ( Exp = = = = = = = = = = = = . ) {tmp.type = 1 ;tmp.x = 0 ;Deal ( TMP ) ;tmp.type = 0 ;tmp.op = ;Deal ( TMP ;I + + ) ;} else {tmp.
type = 0 ;tmp.op = exp i + ;Deal ( TMP ) ;} } } while ( !Sta.Empty ( ) ) {ans num + = sta.Top ( ) ;sta.Pop ( ) ;} / / for ( I = 0 ;i< ;num ;I + + ) / / output postfix expression / / ANS .
Print ( ) ;/ / printf ( n ) ;return 0 ;} int Expression: :Operate ( int a ,char b ,int c ) {if ( b = = ;return c& ;a ) ;if ( b = = ) return CA ;if ( b = = ) return A ;} void Expression: :BiliBili ( ) {for ( int i = 0 ;i< ;num ;I + + ) if ( ANS i .
Type ) ans y = f ans I . X ;} int Expression: :Calc ( ) {int x = 0 ,a ,B ;Node TMP ;sta.Clear ( ) ;for ( int i = 0 ;i< ;num ;I + + ) {if ( ANS .
Type sta.Push ( ANS ) ) ;else {a = sta.Top ( ) . Y ( ) ;sta.Pop ;b = sta.Top ( ) . Y ( ) ;sta.Pop ;tmp.type = 1 ;tmp.y = Operate ( a ,ans I . OP ,b ) ;sta.Push ( TMP ) ;} } if ( sta.
Size ) ( return 1 != 1 );/ / printf ( %s = %d n ,exp ,sta.Top ) . X ( ) ;return sta.Top ( ) . Y ;} / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / Expression Exp1 ,exp2 ;bool check ( ) { for ( wokao = 0 ;wokao< ;( 1<< ;n ) ;wokao + + ) {f = 1 ;for ( int i = 1 ;i< ;n ;I + + ) f = ( ( wokao& ;1<< ;> ( i-1 )) ) ;> ;( i-1 );exp1.
bilibili ( ) ;exp2.bilibili ( ) ;if ( exp1.Calc ( ) != exp2.Calc ( return false ) ) ;} return true ;} int main ( ) {while ( exp1.Input ) ( & ;& ;exp2.Input ( ) ) {n = 0 ;name.
Source by the beats by dre relate article:

没有评论:

发表评论