import java.util.Calendar; import java.util.GregorianCalendar; public class Main { // 日(1~31)を分割して足した場合 29日 の 11 が最大値となる static final int SUM_OF_SPLIT_DAY_MAX = 11; public static void main(String[] args) { Calendar cal = GregorianCalendar.getInstance(); cal.set(2015, 0, 1); // (1 月は 0) int happyDays = 0; int month = 1; int date = 1; int sumOfSplitDay; while (cal.get(Calendar.YEAR) == 2015) { month = cal.get(Calendar.MONTH) + 1; if (month > SUM_OF_SPLIT_DAY_MAX) { cal.add(Calendar.MONTH, 1); cal.set(Calendar.DATE, 1); break; } while (cal.get(Calendar.MONTH) + 1 == month) { date = cal.get(Calendar.DATE); // sumOfSplitDay = date / 10 + date % 10; if (month == sumOfSplitDay ) { happyDays++; // System.out.println(month + "/" + date); } cal.add(Calendar.DATE, 1); } } System.out.println(happyDays); } }