---
# System prepended metadata

title: 20191214TOI新手同好會4.數位邏輯運算

---

# 20191214TOI新手同好會4.數位邏輯運算

---

題目連結：https://zerojudge.tw/ShowProblem?problemid=e797

---

```clike=
#include<iostream>
using namespace std;

int main(){
	int n, t, i, j;
	int b[10][10];
	int ans[3][10];
	for(i = 0; i < 3; i++){
		for(j = 0; j < 10; j++)
			ans[i][j] = 0; 
	}
	cin >> n >> t;
	for(i = 0; i < n; i++){
		for(j = 0; j < t; j++)
			cin >> b[i][j];
	}
	for(j = 0; j < t; j++){
		int time = 0;
		for(i = 0; i < n; i++){
			if(b[i][j] == 1)
				time++;
		}
		if(time == n)
			ans[0][j] = 1;
		if(time >= 1)
			ans[1][j] = 1;
		if(time % 2 == 1)
			ans[2][j] = 1;
	}
	cout << "AND: ";
	for(j = 0; j < t; j++)
		cout << ans[0][j] << " ";
	cout << endl << " OR: ";
	for(j = 0; j < t; j++)
		cout << ans[1][j] << " ";
	cout << endl << "XOR: ";
	for(j = 0; j < t; j++)
		cout << ans[2][j] << " ";
	return 0;
} 
```