Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
124068 | 柯轶炜 | 18岁生日 | Python3 | Accepted | 38 MS | 4056 KB | 593 | 2025-07-10 22:14:23 |
import datetime def is_leap(year): return (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0) def calculate_days(birth_str): year, month, day = map(int, birth_str.split('-')) # 检查是否为2月29日且18年后不是闰年 if month == 2 and day == 29 and not is_leap(year + 18): return -1 birth_date = datetime.date(year, month, day) end_date = datetime.date(year + 18, month, day) return (end_date - birth_date).days T = int(input()) for _ in range(T): birth = input().strip() print(calculate_days(birth))