CF784E. Twisted Circuit 求教

E. Twisted Circuit

time limit per test

2 seconds

memory limit per test

64 megabytes

Input

The input consists of four lines, each line containing a single digit 0 or 1.

Output

Output a single digit, 0 or 1.

Example

Input

0
1
1
0

Output

0

a = bool(input())
b = bool(input())
c = bool(input())
d = bool(input())
x1 = a or b
x2 = c != d
x3 = b and c
x4 = a or d
y1 = x1 and x2
y2 = x3 != x4
print(int(y1 or y2))

为什么答案是这个:

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << ((((a^b)&(c|d))^((b&c)|(a^d)))) << endl;
 
	return 0;
}

看看题解/Editorial:

784E - Twisted Circuit

The picture shows a logic circuit which converts four input signals into one output. To make things more complex, logic gates OR and XOR are pictured swapped (i.e. image of OR gate actually means apply XOR gate).

有没有可能,这是愚人节比赛,大家做着玩的。。。

1 Like