結果
問題 | No.523 LED |
ユーザー | kimiyuki |
提出日時 | 2017-06-02 22:34:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 932 bytes |
コンパイル時間 | 409 ms |
コンパイル使用メモリ | 49,920 KB |
実行使用メモリ | 81,004 KB |
最終ジャッジ日時 | 2024-09-21 22:31:47 |
合計ジャッジ時間 | 1,947 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <cstdio> #include <vector> #include <cassert> #define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i)) using ll = long long; using namespace std; ll powmod(ll x, ll y, ll p) { // O(log y) assert (0 <= x and x < p); assert (0 <= y); ll z = 1; for (ll i = 1; i <= y; i <<= 1) { if (y & i) z = z * x % p; x = x * x % p; } return z; } ll inv(ll x, ll p) { // p must be a prime, O(log p) assert ((x % p + p) % p != 0); return powmod(x, p-2, p); } template <int mod> int fact(int n) { static vector<int> memo(1,1); if (memo.size() <= n) { int l = memo.size(); memo.resize(n+1); repeat_from (i,l,n+1) memo[i] = memo[i-1] *(ll) i % mod; } return memo[n]; } constexpr int mod = 1e9+7; int main() { int n; scanf("%d", &n); int ans = fact<mod>(2*n) * inv(powmod(2, n, mod), mod) % mod; printf("%d\n", ans); return 0; }