結果

問題 No.523 LED
ユーザー Manuel1024Manuel1024
提出日時 2023-01-10 04:47:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 489 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 72,516 KB
実行使用メモリ 315,676 KB
最終ジャッジ日時 2023-08-23 06:02:11
合計ジャッジ時間 5,094 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 8 ms
6,708 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 489 ms
315,676 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 5 ms
5,096 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 69 ms
62,948 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 448 ms
315,448 KB
testcase_19 AC 125 ms
114,048 KB
testcase_20 AC 110 ms
101,348 KB
testcase_21 AC 321 ms
237,036 KB
testcase_22 AC 368 ms
265,184 KB
testcase_23 AC 304 ms
265,136 KB
testcase_24 AC 10 ms
8,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

struct Combination{
    using ll = long long;
    const int n;
    vector<ll> fac, ifac;
    ll mp(ll a, ll x) const {
        ll res = 1;
        for(; x > 0; x >>= 1){
            if(x&1){
                res *= a; res %= MOD;
            }
            a *= a; a %= MOD;
        }
        return res;
    }
    Combination(int _n = 1000000): n(_n), fac(vector<ll>(_n+1)), ifac(vector<ll>(_n+1)){
        fac[0] = 1;
        for(int i = 1; i <= n; i++) fac[i] = (fac[i-1]*i)%MOD;
        ifac[n] = mp(fac[n], MOD-2);
        for(int i = n; i > 0; i--) ifac[i-1] = (ifac[i]*i)%MOD;
    }

    ll operator()(int n, int k) const {
        if (k < 0 || k > n) return 0;
        return fac[n]*ifac[k]%MOD*ifac[n-k]%MOD;
    }
};

int main(){
    int n; cin >> n;
    Combination comb{n*2+10};
    ll ans = comb.fac[n*2];
    for(int i = 0; i < n; i++){
        ans *= comb.ifac[2];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
0