/* * ii.C * * Copyright 2009 Contest team 42 */ #include #include #include #include using namespace std; int main(int argc, char** argv) { char tmp[20]; string line; int day,month,year,parity,a,b,i; int rc; int pos_lomitko; bool boy; //cout << sizeof(long long) << endl; istringstream iss; while(1){ cin.getline(tmp,20); line = tmp; if(line.length() > 11) { cout << "invalid" << endl; continue; } if (line == "end") break; //istringstream iss(line); pos_lomitko = line.find('/',0); if (pos_lomitko != 6 || (line.length() - pos_lomitko - 1 != 4 && line.length() - pos_lomitko - 1 != 3)){ cout << "invalid" << endl; continue; } for(i=0; i<5; i++){ if (line[i] > '9' || line[i] < '0'){ cout << "invalid" << endl; continue; } } if (line[6] != '/'){ cout << "invalid" << endl; continue; } for(i=7; i '9' || line[i] < '0'){ cout << "invalid" << endl; continue; } } //cout << pos_lomitko; iss.clear(); iss.str(line.substr(0,2)); //tmp = iss.str().c_str(); //sscanf(&tmp, "%d", &year); iss >> year; //cout << iss.str() << endl; //cout << year << endl; iss.clear(); iss.str(line.substr(2,2)); iss >> month; iss.clear(); iss.str(line.substr(4,2)); iss >> day; iss.clear(); iss.str(line.substr(pos_lomitko+1,line.length() - pos_lomitko - 1)); iss >> parity; if (year > 9 && year < 20){ cout << "invalid" << endl; continue; } if (year < 54 && year >= 20){ if (line.length() > 10){ cout << "invalid" << endl; continue; } } else{ rc = 0; for (a=0; a<6; a++){ iss.clear(); iss.str(line.substr(a,1)); iss >> b; rc += b * pow(-1,a); } for (a=7; a<11; a++){ iss.clear(); iss.str(line.substr(a,1)); iss >> b; rc += b * pow(-1,a+1); } //rc = parity + day * 10000 + month * 1000000 + year * 100000000; //a = rc % 11; if (rc % 11 != 0){ cout << "invalid" << endl; continue; } } if (month > 50){ boy = false; month -= 50; } else{ boy = true; } if (month < 1 || month > 12){ cout << "invalid" << endl; continue; } else{ if (day < 1){ cout << "invalid" << endl; continue; } if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){ if (day > 31) { cout << "invalid" << endl; continue; } } else{ if (month == 2){ if ((year % 4 == 0 && day > 29) || (year % 4 != 0 && day > 28)){ cout << "invalid" << endl; continue; } } else if (day > 30){ cout << "invalid" << endl; continue; } } } if (boy) cout << "boy" << endl; else cout << "girl" << endl; } return 0; }