Numbers of the same sign#8864

Numbers of the same sign (Editorial)

Algorithm Analysis

Numbers and have the same sign if n \cdot m > 0.

Algorithm Implementation

Read the input data.

scanf("%d %d", &n, &m);

Depending on the sign of the product n \cdot m, output the corresponding answer.

if (n * m > 0)
    puts("1");
else
    puts("0");

Java Implementation

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner con = new Scanner(System.in);
        int n = con.nextInt();
        int m = con.nextInt();
        if (n * m > 0)
            System.out.println("1");
        else
            System.out.println("0");
        con.close();
    }
}

Python Implementation

Read the input data.

n, m = map(int, input().split())

Depending on the sign of the product n \cdot m, output the corresponding answer.

if n * m > 0:
    print("1")
else:
    print("0")