Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
111461 | 汤奕硕 | 闰年的数量 | C++ | Accepted | 1 MS | 268 KB | 468 | 2025-03-02 11:32:06 |
#include <iostream> using namespace std; int main() { int x, y; cin >> x >> y; // 读取输入的两个年份 int count = 0; // 初始化闰年计数器 for (int year = x; year <= y; ++year) { // 判断闰年条件 if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { count++; // 满足条件则计数增加 } } cout << count << endl; // 输出结果 return 0; }
------Input------
685 1586
------Answer-----
218
------Your output-----