Run ID:124068
提交时间: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))