Opposite Signs
Python
Medium
4 views
Problem Description
Read two integers a and b. Output YES if they have opposite signs (one negative, one positive). If any is zero, output NO.
Input Format
One line: a b.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if len(p)<2: sys.exit(0)
a=int(p[0]); b=int(p[1])
if a==0 or b==0:
sys.stdout.write('NO')
else:
sys.stdout.write('YES' if (a<0) != (b<0) else 'NO')
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!