Both Flags Enabled
Programming Basics · Java
TASK
Problem
Two integers `a` and `b` are either 0 or 1. Print `YES` only if both equal 1.
EXAMPLE
Example
1 1
YES
LIMITS
Constraints
a,b ∈ {0,1}
LEARN
Theory for this problem
+
The core idea of **Both Flags Enabled** is to model the requested operation directly: Two integers `a` and `b` are either 0 or 1. Print `YES` only if both equal 1. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.
NEED HELP?
Hints
+
['Follow the statement for **Both Flags Enabled** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']
ANSWER
Solution
+
// CodeMaster — Both Flags Enabled
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
boolean ok = a == 1 && b == 1;
System.out.println(ok ? "YES" : "NO");
}
}