Run ID:147915

提交时间:2026-02-09 08:36:15

#include <iostream> #include <sstream> #include <string> using namespace std; bool isLeapYear(int year) { return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0); } int main() { int T; cin >> T; while (T--) { string dateStr; cin >> dateStr; stringstream ss(dateStr); int year, month, day; char dash1, dash2; ss >> year >> dash1 >> month >> dash2 >> day; int sum = 0; if (month == 2 && day == 29) { cout << -1 << endl; } else { int startYear = (month > 2)? year + 1 : year; for (int i = 0; i < 18; i++) { sum += isLeapYear(startYear + i)? 366 : 365; } cout << sum << endl; } } return 0; }