結果

問題 No.87 Advent Calendar Problem
ユーザー aaaaaaiu
提出日時 2019-08-24 01:34:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 508 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 192,100 KB
最終ジャッジ日時 2025-01-07 14:47:34
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin>>n;
    int d=0;
    int p400=0;
    for(int i=2015;i<=2014+400;i++){
		if (i%400==0||i%100!=0&&i%4==0) d+=2;
		else d++;
		d%=7;
		if (d==0) p400++;
	}
    ll ans=(n-2014)/400*p400;
    int remain=(n-2014)%400;
    d=0;
    for (int i=2015;i<=2014+remain;i++) {
        if (i%400==0||i%100!=0&&i%4==0) d+=2;
        else d++;
        d%=7;
        if (d==0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}
0