Logo
(追記) (追記ここまで)

22539번 - Testing Circuits 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB111100.000%

문제

A Boolean expression is given. In the expression, each variable appears exactly once. Calculate the number of variable assignments that make the expression evaluate to true.

입력

A data set consists of only one line. The Boolean expression is given by a string which consists of digits, x, (, ), |, &, and . Other characters such as spaces are not contained. The expression never exceeds 1,000,000 characters. The grammar of the expressions is given by the following BNF.

<expression> ::= <term> | <expression> "|" <term>
<term> ::= <factor> | <term> "&" <factor>
<factor> ::= <variable> | " " <factor> | "(" <expression> ")"
<variable> ::= "x" <number>
<number> ::= "1" | "2" |... | "999999" | "1000000"

The expression obeys this syntax and thus you do not have to care about grammatical errors. When the expression contains N variables, each variable in {x1, x2,..., xN} appears exactly once.

출력

Output a line containing the number of variable assignments that make the expression evaluate to true in modulo 1,000,000,007.

제한

예제 입력 1

(x1&x2)

예제 출력 1

1

예제 입력 2

(x1&x2)|(x3&x4)|(~(x5|x6)&(x7&x8))

예제 출력 2

121

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Winter Contest > JAG Winter Contest 2012 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /