#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; bool isLeap(int year) { return (year%4 == 0) && (!(year%100 == 0) || (year % 400 == 0)); } const int monthLengths[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; #define INV {cout << "invalid" << endl; continue; } int main(void){ string s; while (cin >> s) { if (s == "end") break; if (s.length() != 10 && s.length() != 11) INV if (s[6] != '/') INV if (!isdigit(s[0])) INV if (!isdigit(s[1])) INV if (!isdigit(s[2])) INV if (!isdigit(s[3])) INV if (!isdigit(s[4])) INV if (!isdigit(s[5])) INV if (!isdigit(s[7])) INV if (!isdigit(s[8])) INV if (!isdigit(s[9])) INV if (s.length() == 11 && !isdigit(s[10])) INV bool isBoy = false; int year = (s[0]-'0')*10 + s[1]-'0'; int month = (s[2]-'0')*10 + s[3]-'0'; int day = (s[4]-'0')*10 + s[5]-'0'; isBoy = (month < 50); if (month > 50) { month -= 50; } // mesic je spravne // den taky if (year >=0 && year <= 9) { if (s.length() != 11) INV year += 2000; } else if (year >=10 && year <= 19) INV else if (year >=20 && year <= 53) { if (s.length() != 10) INV year += 1900; } else if (year >=53 && year <= 99) { if (s.length() != 11) INV year += 1900; } else { cout << "BLBE!" << endl; } // v year je 4ciferny rok if (month <= 0 || month > 12) INV if (day <= 0 || day > monthLengths[month-1]) INV if (!isLeap(year) && month == 2 && day == 29) INV // rozsahy dobre if (!(year >= 1920 && year <= 1953)) { // delitelnost 11 int sum = 0; int parity = 1; for (unsigned i=0; i