結果
問題 | No.87 Advent Calendar Problem |
ユーザー |
![]() |
提出日時 | 2018-03-02 13:49:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 509 bytes |
コンパイル時間 | 654 ms |
コンパイル使用メモリ | 62,260 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-02 21:14:23 |
合計ジャッジ時間 | 1,619 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<iostream>using namespace std;int leap_year(int n){int count = 0, sum = 0;for (int i = 1; i <= n; i++){if ((2014 + i) % 4 == 0){if ((2014 + i) % 100 == 0){if ((2014 + i) % 400 == 0) count += 2;else count++;}else count += 2;}else count++;if (count % 7 == 0) sum++;}return sum;}int main(){long long n;int period, x;cin >> n;period = (n - 2014) / 400;x = (n - 2014) % 400;cout << leap_year(400) * period + leap_year(x) << endl;}