結果
問題 | No.3048 Order and Harmony |
ユーザー | minami |
提出日時 | 2019-04-01 23:59:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,542 bytes |
コンパイル時間 | 1,424 ms |
コンパイル使用メモリ | 171,152 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-27 06:12:12 |
合計ジャッジ時間 | 78,363 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,496 KB |
testcase_01 | AC | 2 ms
8,448 KB |
testcase_02 | AC | 7 ms
10,496 KB |
testcase_03 | TLE | - |
testcase_04 | AC | 1 ms
10,496 KB |
testcase_05 | AC | 2 ms
8,448 KB |
testcase_06 | AC | 5 ms
10,020 KB |
testcase_07 | AC | 2 ms
8,448 KB |
testcase_08 | AC | 5 ms
10,496 KB |
testcase_09 | AC | 2 ms
8,320 KB |
testcase_10 | AC | 5 ms
10,496 KB |
testcase_11 | AC | 2 ms
8,320 KB |
testcase_12 | AC | 2 ms
10,496 KB |
testcase_13 | AC | 2 ms
8,320 KB |
testcase_14 | AC | 2 ms
10,496 KB |
testcase_15 | AC | 7 ms
8,448 KB |
testcase_16 | AC | 1 ms
10,496 KB |
testcase_17 | AC | 1 ms
8,448 KB |
testcase_18 | AC | 2 ms
10,496 KB |
testcase_19 | AC | 8 ms
8,320 KB |
testcase_20 | AC | 6 ms
10,016 KB |
testcase_21 | AC | 6 ms
8,320 KB |
testcase_22 | AC | 4 ms
10,496 KB |
testcase_23 | AC | 2 ms
8,448 KB |
testcase_24 | AC | 2 ms
10,496 KB |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | AC | 2 ms
8,448 KB |
testcase_30 | TLE | - |
testcase_31 | AC | 2 ms
8,448 KB |
testcase_32 | TLE | - |
testcase_33 | AC | 2 ms
8,448 KB |
testcase_34 | TLE | - |
testcase_35 | AC | 2 ms
8,320 KB |
testcase_36 | TLE | - |
testcase_37 | TLE | - |
testcase_38 | AC | 123 ms
10,496 KB |
testcase_39 | TLE | - |
testcase_40 | TLE | - |
testcase_41 | TLE | - |
testcase_42 | TLE | - |
testcase_43 | AC | 2 ms
8,448 KB |
testcase_44 | TLE | - |
testcase_45 | AC | 149 ms
8,320 KB |
testcase_46 | TLE | - |
testcase_47 | TLE | - |
testcase_48 | TLE | - |
testcase_49 | AC | 2 ms
5,248 KB |
testcase_50 | TLE | - |
testcase_51 | AC | 2 ms
5,248 KB |
testcase_52 | AC | 2 ms
5,248 KB |
testcase_53 | TLE | - |
testcase_54 | AC | 2 ms
5,248 KB |
testcase_55 | AC | 1 ms
5,248 KB |
testcase_56 | TLE | - |
testcase_57 | AC | 2 ms
5,248 KB |
testcase_58 | AC | 1 ms
5,248 KB |
testcase_59 | AC | 2 ms
5,248 KB |
testcase_60 | TLE | - |
testcase_61 | TLE | - |
testcase_62 | TLE | - |
testcase_63 | AC | 2 ms
5,248 KB |
testcase_64 | TLE | - |
ソースコード
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = 1'000'000'007; template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } template<int MOD> struct ModInt { static const int kMod = MOD; unsigned x; ModInt() :x(0) {} ModInt(signed x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; } ModInt(signed long long x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; } int get()const { return (int)x; } ModInt &operator+=(ModInt m) { if ((x += m.x) >= MOD)x -= MOD; return *this; } ModInt &operator-=(ModInt m) { if ((x += MOD - m.x) >= MOD)x -= MOD; return *this; } ModInt &operator*=(ModInt m) { x = (unsigned long long)x*m.x%MOD; return *this; } ModInt &operator/=(ModInt m) { return *this *= m.inverse(); } ModInt operator+(ModInt m)const { return ModInt(*this) += m; } ModInt operator-(ModInt m)const { return ModInt(*this) -= m; } ModInt operator*(ModInt m)const { return ModInt(*this) *= m; } ModInt operator/(ModInt m)const { return ModInt(*this) /= m; } ModInt operator-()const { return ModInt(MOD - x); } bool operator==(ModInt m)const { return x == m.x; } bool operator!=(ModInt m)const { return x != m.x; } ModInt inverse()const { signed a = x, b = MOD, u = 1, v = 0; while (b) { signed t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } if (u < 0)u += MOD; return ModInt(u); } }; template<int MOD> ostream &operator<<(ostream &os, const ModInt<MOD> &m) { return os << m.x; } template<int MOD> istream &operator>>(istream &is, ModInt<MOD> &m) { signed long long s; is >> s; m = ModInt<MOD>(s); return is; }; template<int MOD> ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1)r *= a; a *= a; k >>= 1; } return r; } using mint = ModInt<MOD>; // n < 10^7 // 前計算 O(n) // 計算 O(1) // Verified: https://yukicoder.me/submissions/330366 vector<mint> fact, factinv, inv; void precompute(int n) { int m = fact.size(); if (n < m)return; n = min(n, mint::kMod - 1); // N >= kMod => N! = 0 (mod kMod) fact.resize(n + 1); factinv.resize(n + 1); inv.resize(n + 1); if (m == 0) { fact[0] = 1; m = 1; } for (int i = m; i <= n; i++) fact[i] = fact[i - 1] * i; factinv[n] = fact[n].inverse(); for (int i = n; i >= m; i--) factinv[i - 1] = factinv[i] * i; // ((i-1)!)^(-1) = (i!)^(-1) * i for (int i = m; i <= n; i++) inv[i] = factinv[i] * fact[i - 1]; } mint C(int n, int k) { // Lucas's theorem if (n >= mint::kMod) return C(n % mint::kMod, k % mint::kMod) * C(n / mint::kMod, k / mint::kMod); precompute(n); return k > n ? 0 : fact[n] * factinv[n - k] * factinv[k]; } mint P(int n, int k) { precompute(n); return k > n ? 0 : fact[n] * factinv[n - k]; } mint H(int n, int k) { if (n == 0 && k == 0)return 1; // H(0,0) = C(-1,0) = 1 return C(n + k - 1, k); } mint binom(int n, int k) { mint ret = 1; for (int i = 0; i < k; i++) { ret *= n - i; ret /= i + 1; } return ret; } signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; if (N % 2) { cout << 0 << endl; } else { cout << binom(N, N / 2) << endl; } return 0; }