結果

問題 No.727 仲介人moko
ユーザー kakira9618kakira9618
提出日時 2018-08-24 23:07:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 1,000 ms
コード長 2,047 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 144,772 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 13:26:45
合計ジャッジ時間 3,516 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 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 1 ms
4,376 KB
testcase_14 AC 11 ms
4,380 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 AC 11 ms
4,380 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 19 ms
4,376 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 21 ms
4,376 KB
testcase_24 AC 22 ms
4,380 KB
testcase_25 AC 15 ms
4,380 KB
testcase_26 AC 18 ms
4,380 KB
testcase_27 AC 15 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

const int mod = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
    }
    return res;
}

ll a(int n) {
  ll fact2N = 1;
  for(int i = 1; i <= 2 * n; i++) {
    fact2N *= i;
    fact2N %= mod;
  }
  ll power2 = 1;
  for(int i = 0; i < n; i++) {
    power2 *= 2;
    power2 %= mod;
  }
  return (fact2N * mod_pow(power2, mod - 2, mod)) % mod;
}


void solve() {
  /* 
  // The experiment code -> 1, 6, 90, 2520, 113400...
  // found: A000680 (OEIS) 
  // The answer is fact(N) * A000680

  int N;
  cin >> N;
  if (N > 10) {
    exit(1);
    return;
  }
  vector<vector<ll>> dp(1 << N, vector<ll>(1 << N));

  dp[0][0] = 1;
  for(int i = 0; i < 1 << N; i++) {
    for(int j = 0; j < 1 << N; j++) {
      for(int k = 0; k < N; k++) {
        if (!(i >> k & 1)) {
          dp[i | (1 << k)][j] += dp[i][j];
          dp[i | (1 << k)][j] %= mod;
        }
      }
      for(int k = 0; k < N; k++) {
        if ((i >> k & 1) && !(j >> k & 1)) {
          dp[i][j | (1 << k)] += dp[i][j];
          dp[i | (1 << k)][j] %= mod;
        }
      }
    }
  }  
  cout << (dp.back().back()) % mod << endl;
  */

  int N;
  cin >> N;
  ll factN = 1;
  for(int i = 1; i <= N; i++) {
    factN *= i;
    factN %= mod;
  }

  cout << (a(N) * factN) % mod << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}
0