Baekjoon Algorithm | Problem 2753: Leap Year
Source
https://www.acmicpc.net/problem/2753
Problem
Solve Baekjoon Online Judge problem 2753, Leap Year.
Input
Follow the input format and constraints given in the original problem statement.
Output
Print the answer required by the problem.
Sample Input 1
2000
Sample Output 1
1
Sample Input 2
1999
Sample Output 2
0
Algorithm Classification
- Math
- Implementation
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))) {
int input = Integer.parseInt(br.readLine());
if (input % 4 == 0 && (input % 100 != 0 || input % 400 == 0)) {
System.out.println(1);
} else {
System.out.println(0);
}
}
}
}