import java.util.HashMap;
import java.util.Map;
public class CalanderAndLeap {
private static Map<Boolean, int[]> daysMap;
public static void main(String[] args) {
// init
init();
// given
int year = 2017;
int month = 4;
int day = 12;
int sum = countDays(year, month, day);
System.out.println(sum);
}
private static int countDays(int year, int month, int day) {
// isLeap?
int[] targetDays = daysMap.get(isLeap(year));
// 합친다.
int sum = day;
for(int i=0; i<month; i++) {
sum+=targetDays[i];
}
return sum;
}
private static boolean isLeap(int year) {
if((year%4==0&&year%100!=0)||year%400==0) {
return true;
}
return false;
}
private static void init() {
int[] days = { 31,28,31,30,31,30,31,31,30,31,30,31 };
int[] daysLeap = { 31,29,31,30,31,30,31,31,30,31,30,31 };
daysMap = new HashMap<>() ;
daysMap.put(true, daysLeap);
daysMap.put(false, days);
}
}