Problem G
Logic Circuit
Here is a simple logic circuit that has
![\includegraphics[width=0.5\textwidth ]{circuit}](/problems/logiccircuit/file/statement/en/img-0001.png)
The circuit contains three types of logic gates:
-
A NOT gate takes one input
, and outputs if , but otherwise. -
An AND gate takes two inputs
and , and outputs if , but otherwise. -
An OR gate takes two inputs
and , and outputs if , but otherwise.
Write a program that is equivalent to the logic circuit above.
Input
Input consists of three lines. The first line contains the
integer
Output
Output the value of
Sample Input 1 | Sample Output 1 |
---|---|
0 0 0 |
0 |
Sample Input 2 | Sample Output 2 |
---|---|
0 0 1 |
1 |
Sample Input 3 | Sample Output 3 |
---|---|
1 1 1 |
0 |
Sample Input 4 | Sample Output 4 |
---|---|
1 0 0 |
1 |
Sample Input 5 | Sample Output 5 |
---|---|
1 1 0 |
0 |