Baekjoon Algorithm | Problem 14681: Quadrant Selection
Source
https://www.acmicpc.net/problem/14681
Problem
Solve Baekjoon Online Judge problem 14681, Quadrant Selection.
Input
Follow the input format and constraints given in the original problem statement.
Output
Print the answer required by the problem.
Sample Input 1
12 5
Sample Output 1
1
Sample Input 2
9 -13
Sample Output 2
4
Algorithm Classification
- Math
- Implementation
- Geometry
Solution
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
final int x = Integer.parseInt(br.readLine());
final int y = Integer.parseInt(br.readLine());
int q = 0;
if(x >= 0) {
if(y >= 0) {
q = 1;
} else {
q = 4;
}
} else {
if(y >= 0) {
q = 2;
} else {
q = 3;
}
}
System.out.println(q);
}
}
}