結果

問題 No.87 Advent Calendar Problem
ユーザー chocoruskchocorusk
提出日時 2019-07-07 11:58:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 996 bytes
コンパイル時間 774 ms
コンパイル使用メモリ 98,396 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 01:45:25
合計ジャッジ時間 1,704 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll r[2810];
ll cnt[2800];
void init(){
    r[0]=0;
    for(int i=1; i<2800; i++){
        if(i%400==0) r[i]=(r[i-1]+2)%7;
        else if(i%100==0) r[i]=(r[i-1]+1)%7;
        else if(i%4==0) r[i]=(r[i-1]+2)%7;
        else r[i]=(r[i-1]+1)%7;
    }
    if(r[0]==r[2014]) cnt[0]=1;
    for(int i=1; i<2800; i++){
        if(r[i]==r[2014]) cnt[i]=cnt[i-1]+1;
        else cnt[i]=cnt[i-1];
    }
}
ll count(ll n){
    return n/2800*cnt[2799]+cnt[n%2800];
}
int main()
{
    ll n; cin>>n;
    init();
    cout<<count(n)-count(2014)<<endl;
    return 0;
}
0