Quiz
https://atcoder.jp/contests/arc002/tasks/arc002_2
Submit
https://atcoder.jp/contests/arc002/submissions/4120342
補足
- 意外と大きくなりすぎてしまった
- 再利用する機会があるといいな
struct MyDate{ int year; int month; int day; const static int limit[]; MyDate(int y, int m, int d){ year = y; month = m; day = d; } // 明日の日付インスタンスを返す MyDate tomorrow(){ int d = day; int m = month; int y = year; d++; if(day_limit() < d){ d = 1; m++; if(m > 12){ m = 1; y++; } } return MyDate(y, m, d); } // 今月は何日まであるか int day_limit(){ if(month==2){ if(uruu(year)){ return 29; }else{ return 28; } }else{ return limit[month]; } } bool uruu(int y){ if(y%400==0){ return true; } else if(y%100==0){ return false; } else if(y%4==0){ return true; } else{ return false; } } string ToString(){ stringstream ss; ss << "y, m, d " << year << " " << month << " " << day; return ss.str(); } }; const int MyDate::limit[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};