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

19373번 - Bit Operations 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB397717.949%

문제

You are given $N$ pairs of integers $(x_i, y_i)$. Construct a function $f$ that satisfies $y_i = f(x_i)$ for each $i$. It must be possible to write the function $f$ in the C programming language in the following form:

uint32_t f(uint32_t x) {
 return Expression;
}

Here, uint32_t is an unsigned 32-bit integer. The Expression must satisfy the following BNF:

<expr> ::= "x"
 | <num>
 | "(~" <expr> ")"
 | "(" <expr> <op2> <expr> ")"
<op2> ::= "&" | "|" | "^" | "+" | "-" | "*"

Here, <num> is an unsigned 32-bit integer represented as a decimal number. It must not contain leading zeroes, except if it is zero itself which must be represented as 0ドル$.

입력

The first line contains an integer $N$ (1ドル \le N \le 8$).

The $i$-th of the next $N$ lines contains two integers $x_i$ and $y_i$ (0ドル \le x_i, y_i < 256$).

출력

Print an expression that satisfies the conditions.

The output must strictly follow the BNF format in the statement. Extra whitespaces, newlines, parentheses, etc.~are not allowed. The output must contain at most 10ドル^5$ characters. It is guaranteed that the answer exists for the given input.

제한

예제 입력 1

8
1 1
2 2
3 3
4 0
5 1
6 2
7 3
8 0

예제 출력 1

(x&3)

예제 입력 2

8
1 0
2 0
3 2
4 0
5 4
6 4
7 6
8 0

예제 출력 2

(x&(x-1))

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 3: Japanese Contest, Head of Republic of Karelia Cup, Round I D번

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

출처

대학교 대회

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

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