Algorithm Analysis
Numbers and have the same sign if .
Algorithm Implementation
Read the input data.
scanf("%d %d", &n, &m);
Depending on the sign of the product , 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 , output the corresponding answer.
if n * m > 0: print("1") else: print("0")