paizaラーニングレベルアップ問題集の【論理演算メニュー】をやってみた（「基本」編）

paizaラーニングレベルアップ問題集の【論理演算メニュー】をやってみました。
まずは「基本」と名の付く7問です。
- - -
##### 問題
###### 論理積(AND)の基本
https://paiza.jp/works/mondai/logical_operation/logical_operation__basic_step1
###### 論理和(OR)の基本
https://paiza.jp/works/mondai/logical_operation/logical_operation__basic_step2
###### 否定(NOT)の基本
https://paiza.jp/works/mondai/logical_operation/logical_operation__basic_step3
###### 排他的論理和(XOR)の基本
https://paiza.jp/works/mondai/logical_operation/logical_operation__basic_step4
###### NAND演算の基本
https://paiza.jp/works/mondai/logical_operation/logical_operation__basic_step5
###### NOR演算の基本
https://paiza.jp/works/mondai/logical_operation/logical_operation__basic_step6
###### XNOR演算の基本
https://paiza.jp/works/mondai/logical_operation/logical_operation__basic_step7
- - -
##### 方針
今回の入力値は`0`, `1`の二値なので
- ビット演算子（オペランド及び返却値が整数型）を用いる場合
- 論理演算子（オペランド及び返却値が真偽値型）を用いる場合

でやってみます。
###### 否定(NOT)の基本
今回は
- ビット反転させて、1との論理積を取ることにより最下位ビットを取得する

方式を採用していますが、他に
- 1との排他的論理和を取る
- 1から引く（公式解説）

等の方式があります。
###### 排他的論理和(XOR)の基本
論理演算子においては、比較演算子`!=`を用いています。
###### NXORの基本
`a==b`でも答えなのですが、今回は「排他的論理和の否定を取る」ことにしています。
- - -
##### C
###### 論理積(AND)の基本
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", a & b);
	return 0;
}
```
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", a && b);
	return 0;
}
```
###### 論理和(OR)の基本
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", a | b);
	return 0;
}
```
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", a || b);
	return 0;
}
```
###### 否定(NOT)の基本
```c
#include <stdio.h>

int main() {
	int a;
	scanf("%d", &a);
	printf("%d\n", ~a & 1);
	return 0;
}
```
```c
#include <stdio.h>

int main() {
	int a;
	scanf("%d", &a);
	printf("%d\n", !a);
	return 0;
}
```
###### 排他的論理和(XOR)の基本
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", a ^ b);
	return 0;
}
```
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", a != b);
	return 0;
}
```
###### NAND演算の基本
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", ~(a & b) & 1);
	return 0;
}
```
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", !(a && b));
	return 0;
}
```
###### NOR演算の基本
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", ~(a | b) & 1);
	return 0;
}
```
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", !(a || b));
	return 0;
}
```
###### XNOR演算の基本
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", ~(a ^ b) & 1);
	return 0;
}
```
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", !(a != b));
	return 0;
}
```
- - -
##### C++
###### 論理積(AND)の基本
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a & b) << endl;
	return 0;
}
```
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a && b) << endl;
	return 0;
}
```
###### 論理和(OR)の基本
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a | b) << endl;
	return 0;
}
```
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a || b) << endl;
	return 0;
}
```
###### 否定(NOT)の基本
```cpp
#include <iostream>
using namespace std;

int main() {
	int a;
	cin >> a;
	cout << (~a & 1) << endl;
	return 0;
}
```
```cpp
#include <iostream>
using namespace std;

int main() {
	int a;
	cin >> a;
	cout << !a << endl;
	return 0;
}
```
###### 排他的論理和(XOR)の基本
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a ^ b) << endl;
	return 0;
}
```
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a != b) << endl;
	return 0;
}
```
###### NAND演算の基本
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (~(a & b) & 1) << endl;
	return 0;
}
```
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << !(a && b) << endl;
	return 0;
}
```
###### NOR演算の基本
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (~(a | b) & 1) << endl;
	return 0;
}
```
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << !(a || b) << endl;
	return 0;
}
```
###### XNOR演算の基本
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (~(a ^ b) & 1) << endl;
	return 0;
}
```
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << !(a != b) << endl;
	return 0;
}
```
- - -
##### C#
###### 論理積(AND)の基本
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = ab[0];
		int b = ab[1];
		Console.WriteLine(a & b);
	}
}
```
```cs
using System;

class Program
{
	public static void Main()
	{
		bool[] ab = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) != 0);
		bool a = ab[0];
		bool b = ab[1];
		Console.WriteLine(a && b ? 1 : 0);
	}
}
```
###### 論理和(OR)の基本
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = ab[0];
		int b = ab[1];
		Console.WriteLine(a | b);
	}
}
```
```cs
using System;

class Program
{
	public static void Main()
	{
		bool[] ab = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) != 0);
		bool a = ab[0];
		bool b = ab[1];
		Console.WriteLine(a || b ? 1 : 0);
	}
}
```
###### 否定(NOT)の基本
```cs
using System;

class Program
{
	public static void Main()
	{
		int a = int.Parse(Console.ReadLine());
		Console.WriteLine(~a & 1);
	}
}
```
```cs
using System;

class Program
{
	public static void Main()
	{
		bool a = int.Parse(Console.ReadLine()) != 0;
		Console.WriteLine(!a ? 1 : 0);
	}
}
```
###### 排他的論理和(XOR)の基本
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = ab[0];
		int b = ab[1];
		Console.WriteLine(a ^ b);
	}
}
```
```cs
using System;

class Program
{
	public static void Main()
	{
		bool[] ab = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) != 0);
		bool a = ab[0];
		bool b = ab[1];
		Console.WriteLine(a != b ? 1 : 0);
	}
}
```
###### NAND演算の基本
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = ab[0];
		int b = ab[1];
		Console.WriteLine(~(a & b) & 1);
	}
}
```
```cs
using System;

class Program
{
	public static void Main()
	{
		bool[] ab = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) != 0);
		bool a = ab[0];
		bool b = ab[1];
		Console.WriteLine(!(a && b) ? 1 : 0);
	}
}
```
###### NOR演算の基本
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = ab[0];
		int b = ab[1];
		Console.WriteLine(~(a | b) & 1);
	}
}
```
```cs
using System;

class Program
{
	public static void Main()
	{
		bool[] ab = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) != 0);
		bool a = ab[0];
		bool b = ab[1];
		Console.WriteLine(!(a || b) ? 1 : 0);
	}
}
```
###### XNOR演算の基本
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = ab[0];
		int b = ab[1];
		Console.WriteLine(~(a ^ b) & 1);
	}
}
```
```cs
using System;

class Program
{
	public static void Main()
	{
		bool[] ab = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) != 0);
		bool a = ab[0];
		bool b = ab[1];
		Console.WriteLine(!(a != b) ? 1 : 0);
	}
}
```
- - -
##### Go
###### 論理積(AND)の基本
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(a & b)
}
```
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if (a != 0) && (b != 0) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}
```
###### 論理和(OR)の基本
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(a | b)
}
```
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if (a != 0) || (b != 0) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}
```
###### 否定(NOT)の基本
```go
package main
import "fmt"

func main() {
	var a int
	fmt.Scan(&a)
	fmt.Println(^a & 1)
}
```
```go
package main
import "fmt"

func main() {
	var a int
	fmt.Scan(&a)
	if !(a != 0) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}
```
###### 排他的論理和(XOR)の基本
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(a ^ b)
}
```
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if (a != 0) != (b != 0) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}
```
###### NAND演算の基本
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(^(a & b) & 1)
}
```
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if !((a != 0) && (b != 0)) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}
```
###### NOR演算の基本
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(^(a | b) & 1)
}
```
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if !((a != 0) || (b != 0)) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}
```
###### XNOR演算の基本
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(^(a ^ b) & 1)
}
```
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if !((a != 0) != (b != 0)) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}
```
- - -
##### Java
###### 論理積(AND)の基本
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a & b);
		sc.close();
	}
}
```
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextInt() != 0;
		boolean b = sc.nextInt() != 0;
		System.out.println(a && b ? 1 : 0);
		sc.close();
	}
}
```
###### 論理和(OR)の基本
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a | b);
		sc.close();
	}
}
```
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextInt() != 0;
		boolean b = sc.nextInt() != 0;
		System.out.println(a || b ? 1 : 0);
		sc.close();
	}
}
```
###### 否定(NOT)の基本
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		System.out.println(~a & 1);
		sc.close();
	}
}
```
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextInt() != 0;
		System.out.println(!a ? 1 : 0);
		sc.close();
	}
}
```
###### 排他的論理和(XOR)の基本
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a ^ b);
		sc.close();
	}
}
```
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextInt() != 0;
		boolean b = sc.nextInt() != 0;
		System.out.println(a != b ? 1 : 0);
		sc.close();
	}
}
```
###### NAND演算の基本
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(~(a & b) & 1);
		sc.close();
	}
}
```
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextInt() != 0;
		boolean b = sc.nextInt() != 0;
		System.out.println(!(a && b) ? 1 : 0);
		sc.close();
	}
}
```
###### NOR演算の基本
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(~(a | b) & 1);
		sc.close();
	}
}
```
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextInt() != 0;
		boolean b = sc.nextInt() != 0;
		System.out.println(!(a || b) ? 1 : 0);
		sc.close();
	}
}
```
###### XNOR演算の基本
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(~(a ^ b) & 1);
		sc.close();
	}
}
```
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextInt() != 0;
		boolean b = sc.nextInt() != 0;
		System.out.println(!(a != b) ? 1 : 0);
		sc.close();
	}
}
```
- - -
##### JavaScript
###### 論理積(AND)の基本
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a & b);
```
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a && b ? 1 : 0);
```
###### 論理和(OR)の基本
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a | b);
```
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a || b ? 1 : 0);
```
###### 否定(NOT)の基本
```js
const a = Number(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(~a & 1);
```
```js
const a = Number(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(!a ? 1 : 0);
```
###### 排他的論理和(XOR)の基本
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a ^ b);
```
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a != b ? 1 : 0);
```
###### NAND演算の基本
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(~(a & b) & 1);
```
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(!(a && b) ? 1 : 0);
```
###### NOR演算の基本
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(~(a | b) & 1);
```
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(!(a || b) ? 1 : 0);
```
###### XNOR演算の基本
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(~(a ^ b) & 1);
```
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(!(a != b) ? 1 : 0);
```
- - -
##### Kotlin
###### 論理積(AND)の基本
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	println(a & b)
}
```
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() != 0 }
	println(if (a && b) 1 else 0)
}
```
###### 論理和(OR)の基本
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	println(a or b)
}
```
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() != 0 }
	println(if (a || b) 1 else 0)
}
```
###### XNOR演算の基本
```kotlin
import java.util.*

fun main() {
	val sc = Scanner(System.`in`)
	val a = sc.nextInt()
	sc.close()
	println(a.inv() and 1)
}
```
```kotlin
import java.util.*

fun main() {
	val sc = Scanner(System.`in`)
	val a = sc.nextInt() != 0
	sc.close()
	println(if (!a) 1 else 0)
}
```
###### 排他的論理和(XOR)の基本
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	println(a ^ b)
}
```
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() != 0 }
	println(if (a != b) 1 else 0)
}
```
###### NAND演算の基本
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	println((a and b).inv() and 1)
}
```
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() != 0 }
	println(if (!(a && b)) 1 else 0)
}
```
###### NOR演算の基本
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	println((a or b).inv() and 1)
}
```
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() != 0 }
	println(if (!(a || b)) 1 else 0)
}
```
###### XNOR演算の基本
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	println((a xor b).inv() and 1)
}
```
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() != 0 }
	println(if (!(a != b)) 1 else 0)
}
```
- - -
##### PHP
###### 論理積(AND)の基本
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a & $b, PHP_EOL;
?>
```
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a && $b ? 1 : 0, PHP_EOL;
?>
```
###### 論理和(OR)の基本
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a | $b, PHP_EOL;
?>
```
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a || $b ? 1 : 0, PHP_EOL;
?>
```
###### 否定(NOT)の基本
```php
<?php
	$a = intval(fgets(STDIN));
	echo ~$a & 1, PHP_EOL;
?>
```
```php
<?php
	$a = intval(fgets(STDIN));
	echo !$a ? 1 : 0, PHP_EOL;
?>
```
###### 排他的論理和(XOR)の基本
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a ^ $b, PHP_EOL;
?>
```
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a != $b ? 1 : 0, PHP_EOL;
?>
```
###### NAND演算の基本
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo ~($a & $b) & 1, PHP_EOL;
?>
```
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo !($a && $b) ? 1 : 0, PHP_EOL;
?>
```
###### NOR演算の基本
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo ~($a | $b) & 1, PHP_EOL;
?>
```
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo !($a || $b) ? 1 : 0, PHP_EOL;
?>
```
###### XNOR演算の基本
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo ~($a ^ $b) & 1, PHP_EOL;
?>
```
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo !($a != $b) ? 1 : 0, PHP_EOL;
?>
```
- - -
##### Perl
###### 論理積(AND)の基本
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print $a & $b, $/;
```
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print $a && $b ? 1 : 0, $/;
```
###### 論理和(OR)の基本
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print $a | $b, $/;
```
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print $a || $b ? 1 : 0, $/;
```
###### 否定(NOT)の基本
```pl
my $a = int(<STDIN>);
print ~$a & 1, $/;
```
```pl
my $a = int(<STDIN>);
print !$a ? 1 : 0, $/;
```
###### 排他的論理和(XOR)の基本
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print $a ^ $b, $/;
```
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print $a != $b ? 1 : 0, $/;
```
###### NAND演算の基本
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print ~($a & $b) & 1, $/;
```
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print !($a && $b) ? 1 : 0, $/;
```
###### NOR演算の基本
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print ~($a | $b) & 1, $/;
```
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print !($a || $b) ? 1 : 0, $/;
```
###### XNOR演算の基本
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print ~($a ^ $b) & 1, $/;
```
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print !($a != $b) ? 1 : 0, $/;
```
- - -
##### Python3
###### 論理積(AND)の基本
```py
a, b = map(int, input().split())
print(a & b)
```
```py
a, b = map(int, input().split())
print(a and b)
```
###### 論理和(OR)の基本
```py
a, b = map(int, input().split())
print(a | b)
```
```py
a, b = map(int, input().split())
print(a or b)
```
###### 否定(NOT)の基本
```py
a = int(input())
print(~a & 1)
```
```py
a = int(input())
print(int(not a))
```
###### 排他的論理和(XOR)の基本
```py
a, b = map(int, input().split())
print(a ^ b)
```
```py
a, b = map(int, input().split())
print(int(a != b))
```
###### NAND演算の基本
```py
a, b = map(int, input().split())
print(~(a & b) & 1)
```
```py
a, b = map(int, input().split())
print(int(not (a and b)))
```
###### NOR演算の基本
```py
a, b = map(int, input().split())
print(~(a | b) & 1)
```
```py
a, b = map(int, input().split())
print(int(not (a or b)))
```
###### XNOR演算の基本
```py
a, b = map(int, input().split())
print(~(a ^ b) & 1)
```
```py
a, b = map(int, input().split())
print(int(not a != b))
```
- - -
##### Ruby
###### 論理積(AND)の基本
```rb
a, b = gets.split.map(&:to_i)
p a & b
```
```rb
a, b = gets.split.map { |x| x.to_i != 0 }
p a && b ? 1 : 0
```
###### 論理和(OR)の基本
```rb
a, b = gets.split.map(&:to_i)
p a | b
```
```rb
a, b = gets.split.map { |x| x.to_i != 0 }
p a || b ? 1 : 0
```
###### 否定(NOT)の基本
```rb
a = gets.to_i
p ~a & 1
```
```rb
a = gets.to_i != 0
p !a ? 1 : 0
```
###### 排他的論理和(XOR)の基本
```rb
a, b = gets.split.map(&:to_i)
p a ^ b
```
```rb
a, b = gets.split.map { |x| x.to_i != 0 }
p a != b ? 1 : 0
```
###### NAND演算の基本
```rb
a, b = gets.split.map(&:to_i)
p ~(a & b) & 1
```
```rb
a, b = gets.split.map { |x| x.to_i != 0 }
p !(a && b) ? 1 : 0
```
###### NOR演算の基本
```rb
a, b = gets.split.map(&:to_i)
p ~(a | b) & 1
```
```rb
a, b = gets.split.map { |x| x.to_i != 0 }
p !(a || b) ? 1 : 0
```
###### XNOR演算の基本
```rb
a, b = gets.split.map(&:to_i)
p ~(a ^ b) & 1
```
```rb
a, b = gets.split.map { |x| x.to_i != 0 }
p !(a != b) ? 1 : 0
```
- - -
##### Scala
###### 論理積(AND)の基本
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	println(a & b)
}
```
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt != 0 }
	println(if (a && b) 1 else 0)
}
```
###### 論理和(OR)の基本
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	println(a | b)
}
```
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt != 0 }
	println(if (a || b) 1 else 0)
}
```
###### 否定(NOT)の基本
```scala
import java.util._

object Main extends App{
	val sc = new Scanner(System.in)
	val a = sc.nextInt()
	sc.close()
	println(~a & 1)
}
```
```scala
import java.util._

object Main extends App{
	val sc = new Scanner(System.in)
	val a = sc.nextInt() != 0
	sc.close()
	println(if (!a) 1 else 0)
}
```
###### 排他的論理和(XOR)の基本
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	println(a ^ b)
}
```
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt != 0 }
	println(if (a != b) 1 else 0)
}
```
###### NAND演算の基本
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	println(~(a & b) & 1)
}
```
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt != 0 }
	println(if (!(a && b)) 1 else 0)
}
```
###### NOR演算の基本
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	println(~(a | b) & 1)
}
```
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt != 0 }
	println(if (!(a || b)) 1 else 0)
}
```
###### XNOR演算の基本
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	println(~(a ^ b) & 1)
}
```
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt != 0 }
	println(if (!(a != b)) 1 else 0)
}
```
- - -
##### Swift
###### 論理積(AND)の基本
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
print(a & b)
```
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) != 0 }
let (a, b) = (ab[0], ab[1])
print(a && b ? 1 : 0)
```
###### 論理和(OR)の基本
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
print(a | b)
```
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) != 0 }
let (a, b) = (ab[0], ab[1])
print(a || b ? 1 : 0)
```
###### 否定(NOT)の基本
```swift
let a = Int(readLine()!)!
print(~a & 1)
```
```swift
let a = Int(readLine()!)! != 0
print(!a ? 1 : 0)
```
###### 排他的論理和(XOR)の基本
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
print(a ^ b)
```
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) != 0 }
let (a, b) = (ab[0], ab[1])
print(a != b ? 1 : 0)
```
###### NAND演算の基本
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
print(~(a & b) & 1)
```
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) != 0 }
let (a, b) = (ab[0], ab[1])
print(!(a && b) ? 1 : 0)
```
###### NOR演算の基本
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
print(~(a | b) & 1)
```
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) != 0 }
let (a, b) = (ab[0], ab[1])
print(!(a || b) ? 1 : 0)
```
###### XNOR演算の基本
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
print(~(a ^ b) & 1)
```
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) != 0 }
let (a, b) = (ab[0], ab[1])
print(!(a != b) ? 1 : 0)
```