PROBLEM 43
Medium

Exactly One Positive

Programming Basics · C++

</>
STATUS Not solved

TASK

Problem

#43

Two integers `a` and `b` are given. Print `YES` if exactly one is positive; otherwise print `NO`.

EXAMPLE

Example

Input
-2 3
Output
YES

LIMITS

Constraints

All values are integers with magnitude at most 10^9.
📖
LEARN Theory for this problem
+

Logical AND `&&`, OR `||`, and negation `!` combine boolean conditions. Parentheses make the intended grouping explicit.

Connection to “Exactly One Positive”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.

💡
NEED HELP? Hints
+

['Translate the verbal condition into one boolean expression.', 'After solving “Exactly One Positive”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']

ANSWER Solution
+
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
    long long a, b;
    cin >> a >> b;
    cout << (((a > 0) != (b > 0)) ? "YES" : "NO") << '\n';
    return 0;
}