//本题利用Hash思想,将对应平闰年各月分天数存储,免去条件判断
#include<iostream> #include<cstring> #include<stdio.h> using namespace std; int dofm[2][12] = {31, 28 ,31,30,31,30,31,31,30,31,30,31, 31, 29 ,31,30,31,30,31,31,30,31,30,31}; int isR(int year) { int res = 0; if (year%400 == 0) { return 1; } if (year%4 == 0) { if (year%100 == 0) { return 0; } res = 1; } return res; } int main() { int year, day, i,j; while (cin >> year >> day) { j = isR(year); for (i=0; i<12; i++) { if (day > dofm[j][i]) { day -= dofm[j][i]; } else break; } printf("%04d-%02d-%02d ", year, i+1, day); } return 0; }