結果

問題 No.523 LED
ユーザー oxyshoweroxyshower
提出日時 2020-01-23 12:21:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 971 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 167,248 KB
実行使用メモリ 318,740 KB
最終ジャッジ日時 2023-09-26 07:24:29
合計ジャッジ時間 7,805 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 361 ms
318,740 KB
testcase_01 AC 365 ms
159,280 KB
testcase_02 AC 433 ms
159,488 KB
testcase_03 AC 366 ms
159,116 KB
testcase_04 AC 366 ms
159,124 KB
testcase_05 TLE -
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 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; // fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2, MOD) % MOD;
  }

  int mod_pow(int n, int p, int MOD){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;
const int MOD = 1e9 + 7;

signed main(){

  int n; cin >> n;
  int ans = 1;
  comb.init(1e7 * 2);
  for(int i = 1; i <= n; i++){
    ans = (ans * comb.nCr(2 * n - (i-1) * 2, 2)) % MOD;
  }
  cout << ans << endl;

  return 0;
}
0