| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 88986 | sh25_zhangyj | 算天数 | C++ | 解答错误 | 0 MS | 252 KB | 1121 | 2026-05-22 14:36:26 |
#include <iostream> using namespace std; bool isLeap(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); } int daysInMonth(int year, int month) { if (month == 2) return isLeap(year) ? 29 : 28; if (month == 4 || month == 6 || month == 9 || month == 11) return 30; return 31; } long long countDays(int y, int m, int d) { long long total = 0; for (int i = 1; i < y; i++) { total += isLeap(i) ? 366 : 365; } for (int i = 1; i < m; i++) { total += daysInMonth(y, i); } total += d; return total; } int main() { // 今天:2025-05-22,星期四(按题目数字:周一=1,周四=4) const int todayY = 2025, todayM = 5, todayD = 22; const int todayWeek = 4; int y, m, d; cin >> y >> m >> d; long long daysToday = countDays(todayY, todayM, todayD); long long daysFuture = countDays(y, m, d); long long diff = daysFuture - daysToday; int week = (todayWeek - 1 + diff) % 7 + 1; cout << diff << endl; cout << "*" << week << endl; return 0; }