結果
問題 | No.2048 L(I+D)S |
ユーザー | vjudge1 |
提出日時 | 2024-12-30 17:31:10 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 2,944 bytes |
コンパイル時間 | 5,232 ms |
コンパイル使用メモリ | 163,164 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 17:31:17 |
合計ジャッジ時間 | 4,450 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 3 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 18 ms
5,248 KB |
testcase_09 | AC | 7 ms
5,248 KB |
testcase_10 | AC | 6 ms
5,248 KB |
testcase_11 | AC | 20 ms
5,248 KB |
testcase_12 | AC | 11 ms
5,248 KB |
testcase_13 | AC | 7 ms
5,248 KB |
testcase_14 | AC | 8 ms
5,248 KB |
testcase_15 | AC | 5 ms
5,248 KB |
testcase_16 | AC | 20 ms
5,248 KB |
testcase_17 | AC | 22 ms
5,248 KB |
testcase_18 | AC | 20 ms
5,248 KB |
コンパイルメッセージ
main.cpp:18:58: warning: instantiation of variable 'math::mint<998244353>::mod' required here, but no definition is available [-Wundefined-var-template] 18 | static int getmod() { if (P > 0) return P; else return mod; } | ^ main.cpp:17:39: note: in instantiation of member function 'math::mint<998244353>::getmod' requested here 17 | template <class T> mint(T x) { x %= getmod(), v = x < 0 ? x + getmod() : x; } | ^ main.cpp:50:22: note: in instantiation of function template specialization 'math::mint<998244353>::mint<int>' requested here 50 | cin >> n, fac[0] = 1; | ^ main.cpp:16:31: note: forward declaration of template entity is here 16 | unsigned v; static unsigned mod; mint() = default; | ^ main.cpp:18:58: note: add an explicit instantiation declaration to suppress this warning if 'math::mint<998244353>::mod' is explicitly instantiated in another translation unit 18 | static int getmod() { if (P > 0) return P; else return mod; } | ^ 1 warning generated.
ソースコード
#include <bits/stdc++.h> #define REP(i, l, r) for (int i = (l); i <= (r); ++ i) #define DEP(i, r, l) for (int i = (r); i >= (l); -- i) #define fi first #define se second #define pb emplace_back #define mems(x, v) memset((x), (v), sizeof(x)) #define SZ(x) (int)(x).size() #define ALL(x) (x).begin(), (x).end() using namespace std; namespace math { typedef long long LL; template <class T> T qpow(T a, LL b) { if (!b) return {1}; T rs = a; b --; for (; b; b >>= 1, a = a * a) if (b & 1) rs = rs * a; return rs; } LL mul(LL a, LL b, LL p) { LL rs = a * b - LL(1.L * a * b / p) * p; rs %= p; if (rs < 0) rs += p; return rs; } template <unsigned P = 0> struct mint { unsigned v; static unsigned mod; mint() = default; template <class T> mint(T x) { x %= getmod(), v = x < 0 ? x + getmod() : x; } static int getmod() { if (P > 0) return P; else return mod; } static void setmod(unsigned m) { mod = m; } mint operator + () const { return *this; } mint operator - () const { return mint(0) - *this; } mint inv() const { return assert(v), qpow(*this, getmod() - 2); } int val() const { return v; } mint &operator += (const mint &q) { if (v += q.v, v >= getmod()) v -= getmod(); return *this; } mint &operator -= (const mint &q) { if (v -= q.v, v >= getmod()) v += getmod(); return *this; } mint &operator *= (const mint &q) { v = 1ull * v * q.v % getmod(); return *this; } mint &operator /= (const mint &q) { return *this *= q.inv(); } friend mint operator + (mint p, const mint &q) { return p += q; } friend mint operator - (mint p, const mint &q) { return p -= q; } friend mint operator * (mint p, const mint &q) { return p *= q; } friend mint operator / (mint p, const mint &q) { return p /= q; } friend bool operator == (const mint &p, const mint &q) { return p.v == q.v; } friend bool operator != (const mint &p, const mint &q) { return p.v != q.v; } friend bool operator < (const mint &p, const mint &q) { return p.v < q.v; } friend bool operator > (const mint &p, const mint &q) { return p.v > q.v; } friend bool operator <= (const mint &p, const mint &q) { return p.v <= q.v; } friend bool operator >= (const mint &p, const mint &q) { return p.v >= q.v; } friend istream &operator >> (istream &is, mint &a) { is >> a.v; return is; } friend ostream &operator << (ostream &os, const mint &a) { os << a.v; return os; } }; template <> unsigned mint<0>::mod = 998244353; } namespace Milkcat { typedef long long LL; typedef pair<LL, LL> pii; const int N = 1e6 + 5, mod = 998244353; typedef math::mint<mod> MI; int n; MI rs, fac[N]; int main() { cin >> n, fac[0] = 1; REP(i, 1, n) fac[i] = fac[i - 1] * i; REP(i, 2, n - 2) { int j = n - i; MI x = fac[n] / (fac[i - 2] * fac[j - 2] * i * j * (n - 1)); rs += x * x; } cout << rs << '\n'; return 0; } } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int T = 1; while (T --) Milkcat::main(); return 0; }