結果
| 問題 | No.87 Advent Calendar Problem |
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2014-12-07 00:21:42 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 772 bytes |
| 記録 | |
| コンパイル時間 | 321 ms |
| コンパイル使用メモリ | 76,512 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-25 13:54:52 |
| 合計ジャッジ時間 | 1,714 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 22 |
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;
typedef long long LL;
bool is_uruu(LL year) {
return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
}
LL solve(LL N)
{
LL ans = 0;
LL year;
int w = 0;
for (year = 2015; year <= N && year < 400 * 7; ++year) {
int days = 365 + is_uruu(year);
w = (w + days) % 7;
ans += w == 0;
}
LL a = max(0LL, N / (400 * 7) - 1);
ans += a * 400;
year += a * 400 * 7;
for (; year <= N; ++year) {
int days = 365 + is_uruu(year);
w = (w + days) % 7;
ans += w == 0;
}
return ans;
}
int main(int argc, char *argv[])
{
string s;
getline(cin, s);
LL N;
sscanf(s.c_str(), "%lld", &N);
cout << solve(N) << endl;
return 0;
}
hotpepsi