#include <stdio.h> #include <stdbool.h> bool IsRunYear(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); } int table[2][13] = { {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; int main() { int year, month, day; int number; while (scanf("%d%d", & year, & number) != EOF) { month = 0; int row = IsRunYear(year); while (number > table[row][month]) { number -= table[row][month]; month++; } day = number; printf("%d-%02d-%02d", year, month, day); } return 0; }