Algorithm


Problem Name: beecrowd | 2787

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2787

Chess

 

By OBI BR Brasil

Timelimit: 1


In the chessboard, the square of the board on line 1, column 1 (upper left corner) is always white and the colors of the houses alternate between white and black, according to the pattern known as ... chess! In this way, since the traditional board has eight rows and eight columns, the house on row 8, column 8 (lower right corner) will also be white. In this problem, however, we want to know the color of the square of the board in the lower right corner of a tray with any dimensions: L rows and C columns. In the example of the figure, for L = 6 and C = 9, the square of the board in the lower right corner will be black!

 

Input

 

The first line of the input contains an integer L (1 ≤ L ≤ 1000) indicating the number of lines in the chessboard. The second line of the input contains an integer C (1 ≤ C ≤ 1000) representing the number of columns.

 

Output

 

Print a line on the output. The line should contain an integer, representing the color of the house in the lower right corner of the board: 1, if it is white; and 0, if it is black.

 

 

 

Input Samples Output Samples

6

9

0

 

 

 

8

8

1

 

 

 

5

91

1

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
int main ()
{

	unsigned short linha, coluna;

	scanf("%hu %hu", &linha, &coluna);

	if (linha % 2 == 0 && coluna % 2 == 0)
		printf("1\n");
	else if (linha % 2 == 1 && coluna % 2 == 1)
		printf("1\n");
	else
		printf("0\n");

}

Copy The Code & Try With Live Editor

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a+b)%2==0)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Copy The Code & Try With Live Editor

#3 Code Example with Java Programming

Code - Java Programming


import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int L = sc.nextInt();
		int C = sc.nextInt();
		if ((L+C)%2==0)
			System.out.println("1");
		else
			System.out.println("0");
		sc.close();
	}
}
Copy The Code & Try With Live Editor

#4 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("node:fs")

const [L, C] = readFileSync("/dev/stdin", "utf8")
	.split("\n", 2)
	.map(value => Number.parseInt(value, 10))

console.log(
	(L + C) % 2 === 0 ? "1" : "0"
)
Copy The Code & Try With Live Editor
Advertisements

Demonstration


Previous
#2786 Beecrowd Online Judge Solution 2786 School Floor Solution in C, C++, Java, Js and Python
Next
#2791 Beecrowd Online Judge Solution 2791 Bean Solution in C, C++, Java, Js and Python