"Idea": it takes 18 years anyway, so the question is whether the 18 is a leap year. Note: Judging after February from the beginning of the next year 18, before February judged 18 years starting from this year. There is also a special award for the 29 birthday of February. Ps. One year is 365 days, not 356 days!
"AC Code":
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include < Algorithm> #include <iomanip>using namespace std;int isleapyear (int y) { if (y%4==0&&y%100!=0) | | (y%400==0)) return 1; return 0;} int main () { int T = 0; Cin >> T; while (t--) { int year = 0, month = 0, day = 0; int i = 0, days = 0; char c; CIN >> Year >> C >> month >> C >> Day; if (2 = = Month && = = Day && 0 = isleapyear (year+18)) { cout <<-1 << endl; Continue; } if (Month > 2) year + = 1; for (i = 0; i <, i++) { if (isleapyear (year+i)) days + = 366; else days + = 365; } cout << days << endl; } return 0;}
Hdoj 1201-18 Birthday