結果

問題 No.314 ケンケンパ
ユーザー LeonardoneLeonardone
提出日時 2015-12-07 05:54:40
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 846 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 60,084 KB
実行使用メモリ 11,916 KB
最終ジャッジ日時 2023-10-12 19:42:06
合計ジャッジ時間 4,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder My Practice
// author: Leonardone @ NEETSDKASU
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MD = 1000000007LL;
const ull UMD = 1000000007ULL;


ll cmb(ll n, ll c) {
    ll r = 1LL;
    c = min(c, n - c);
    for (ll i = 1; i <= c; i++) {
        r *= n--;
        r /= i;
    }
    return r % MD;
}

ull fnc(ll n) {
    ll c = 0LL;
    ll i = 0LL;
    if (n > 0LL && (n & 1LL)) {
        i = 1LL;
        n -= 3LL;
    }
    ll d = n >> 1;
    while (d >= 0LL) {
        c = (c + cmb(d + i, i)) % MD;
        i += 2LL;
        d -= 3LL;
    }
    return ull(c);
}

void solve() {
    ll n;
    cin >> n;
    
    ull ans = (((fnc(n) + fnc(n - 1)) % UMD) + fnc(n - 2)) % UMD;
    
    cout << ans << endl;
}










int main() { solve(); return 0; }
0