package yukicoder; import java.util.GregorianCalendar; public class Yuki9 { public static void main(String[] args){ GregorianCalendar gc = new GregorianCalendar(2015, 0, 1); String str = ""; int count = 0; while(gc.get(gc.YEAR) < 2016) { //System.out.println("while="+gc.get(gc.YEAR) + "年" + (gc.get(gc.MONTH ) + 1) + "月" + gc.get(gc.DATE) + "日"); str = String.valueOf(((gc.get(gc.DATE)))); int dayTotal = 0; for (int i = 0; i < str.length(); i++ ) { dayTotal += ((int)(str.charAt(i))%48); } if(Integer.valueOf((gc.get(gc.MONTH) + 1)) == dayTotal){ count++; } dayTotal = 0; gc.add(gc.DATE, 1); } System.out.println(count); } }