結果

問題 No.523 LED
ユーザー oxyshoweroxyshower
提出日時 2020-01-23 12:26:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,086 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 167,976 KB
実行使用メモリ 159,496 KB
最終ジャッジ日時 2023-09-26 07:58:42
合計ジャッジ時間 21,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 367 ms
159,196 KB
testcase_01 AC 368 ms
159,120 KB
testcase_02 AC 388 ms
159,188 KB
testcase_03 AC 369 ms
159,200 KB
testcase_04 AC 370 ms
159,284 KB
testcase_05 TLE -
testcase_06 AC 366 ms
159,196 KB
testcase_07 AC 369 ms
159,224 KB
testcase_08 AC 366 ms
159,296 KB
testcase_09 AC 380 ms
159,192 KB
testcase_10 AC 366 ms
159,308 KB
testcase_11 AC 369 ms
159,264 KB
testcase_12 AC 367 ms
159,176 KB
testcase_13 AC 695 ms
159,424 KB
testcase_14 AC 364 ms
159,300 KB
testcase_15 AC 369 ms
159,204 KB
testcase_16 AC 368 ms
159,268 KB
testcase_17 AC 369 ms
159,304 KB
testcase_18 TLE -
testcase_19 AC 972 ms
159,228 KB
testcase_20 AC 902 ms
159,232 KB
testcase_21 AC 1,641 ms
159,176 KB
testcase_22 AC 1,790 ms
159,496 KB
testcase_23 AC 1,791 ms
159,112 KB
testcase_24 AC 399 ms
159,216 KB
権限があれば一括ダウンロードができます

ソースコード

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(n * 2 - (i-1) * 2, 2)) % MOD;
    ans = (ans * (n * 2 - (i-1) * 2) % MOD * (n * 2 - (i-1) * 2 - 1) % MOD * comb.mod_pow(2, MOD-2, MOD)) % MOD;
  }
  cout << ans << endl;

  return 0;
}
0