結果
問題 | No.87 Advent Calendar Problem |
ユーザー |
![]() |
提出日時 | 2021-01-17 17:20:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 2,028 ms |
コンパイル使用メモリ | 191,940 KB |
最終ジャッジ日時 | 2025-01-18 01:46:47 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int64_t n; cin >> n; int64_t k = (n - 2014) / 400, r = (n - 2014) % 400; int64_t ans = 0; int d = 0; for (int i = 2015; i <= r + 2014; i++) { d++; if (i % 4 == 0) d++; if (i % 100 == 0) d--; if (i % 400 == 0) d++; d %= 7; if (d == 0) ans++; } int x = 0; for (int i = n + 1; i <= n + 400; i++) { d++; if (i % 4 == 0) d++; if (i % 100 == 0) d--; if (i % 400 == 0) d++; d %= 7; if (d == 0) x++; } cout << x * k + ans << endl; }