結果
| 問題 |
No.727 仲介人moko
|
| コンテスト | |
| ユーザー |
kakira9618
|
| 提出日時 | 2018-08-24 23:07:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 1,000 ms |
| コード長 | 2,047 bytes |
| コンパイル時間 | 1,589 ms |
| コンパイル使用メモリ | 158,440 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 09:06:05 |
| 合計ジャッジ時間 | 2,610 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 |
ソースコード
#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;
}
kakira9618