163 int day_of_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
164 int day_of_month_leap[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
165 int start_day_of_month[14] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, INT_MAX};
166 while(cin >> year >> day) {
167 bool leap = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
169 for(
int i = 1; i <= 12; i++) {
170 start_day_of_month[i] = start_day_of_month[i - 1] + day_of_month_leap[i - 1];
173 for(
int i = 1; i <= 12; i++) {
174 start_day_of_month[i] = start_day_of_month[i - 1] + day_of_month[i - 1];
177 cout << setw(4) << setfill(
'0') << year <<
'-';
178 for(
int i = 1; i <= 13; i++) {
179 if(start_day_of_month[i] > day) {
180 cout << setw(2) << setfill(
'0') << i - 1 <<
'-';
181 day -= start_day_of_month[i - 1];
183 cout << setw(2) << setfill(
'0') << day << endl;
187 memset(start_day_of_month, 0,
sizeof(start_day_of_month));
188 start_day_of_month[0] = 1;
189 start_day_of_month[13] = INT_MAX;