結果
| 問題 | No.87 Advent Calendar Problem | 
| コンテスト | |
| ユーザー |  hotpepsi | 
| 提出日時 | 2014-12-07 00:21:42 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 772 bytes | 
| コンパイル時間 | 554 ms | 
| コンパイル使用メモリ | 60,860 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-11 15:54:48 | 
| 合計ジャッジ時間 | 1,297 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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;
}
            
            
            
        