結果

問題 No.523 LED
ユーザー Manuel1024
提出日時 2023-01-10 04:47:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 72,000 KB
実行使用メモリ 315,728 KB
最終ジャッジ日時 2024-12-21 06:19:29
合計ジャッジ時間 3,654 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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