Hide

Problem G
Logic Circuit

Here is a simple logic circuit that has $3$ inputs, $A$, $B$, and $C$, and $1$ output $D$.

\includegraphics[width=0.5\textwidth ]{circuit}
Figure 1: The logic circuit

The circuit contains three types of logic gates:

  • A NOT gate takes one input $x$, and outputs $1$ if $x=0$, but $0$ otherwise.

  • An AND gate takes two inputs $x$ and $y$, and outputs $1$ if $x=y=1$, but $0$ otherwise.

  • An OR gate takes two inputs $x$ and $y$, and outputs $0$ if $x=y=0$, but $1$ otherwise.

Write a program that is equivalent to the logic circuit above.

Input

Input consists of three lines. The first line contains the integer $A$, where $A$ is either $0$ or $1$. The second line contains the integer $B$, where $B$ is either $0$ or $1$. The third line contains the integer $C$, where $C$ is either $0$ or $1$.

Output

Output the value of $D$, which is either $0$ or $1$.

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

Please log in to submit a solution to this problem

Log in