Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
148105 于墨轩 18岁生日 C++ Wrong Answer 1 MS 276 KB 1070 2026-02-09 16:52:42

Tests(0/1):


Code:

#include <iostream> #include <string> using namespace std; bool isLeapYear(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); } int daysInMonth(int month, int year) { int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (month == 2 && isLeapYear(year)) { return 29; } return days[month - 1]; } int daysFromBirthTo18thBirthday(int year, int month, int day) { int targetYear = year + 18; if (month == 2 && day == 29 && !isLeapYear(targetYear)) { return -1; } int totalDays = 0; for (int y = year; y < targetYear; y++) { totalDays += isLeapYear(y) ? 366 : 365; } return totalDays; } int main() { int T; cin >> T; for (int i = 0; i < T; i++) { string date; cin >> date; int year, month, day; sscanf(date.c_str(), "%d-%d-%d", &year, &month, &day); int result = daysFromBirthTo18thBirthday(year, month, day); cout << result << endl; } return 0; }


Run Info:

------Input------
11 1989-11-26 1962-12-02 1963-03-27 1990-03-31 1900-02-28 2000-02-29 2008-08-08 1995-02-28 2012-02-29 2020-02-28 1982-03-01
------Answer-----
6574 6575 6575 6575 6574 -1 6574 6575 -1 6575 6575
------Your output-----
6574 6574 6575 6574 6574 -1 6575 6575 -1 6575 6574