結果

問題 No.2511 Mountain Sequence
ユーザー rogi52rogi52
提出日時 2023-10-20 23:25:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 8,049 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 205,156 KB
実行使用メモリ 15,012 KB
最終ジャッジ日時 2024-09-20 23:13:43
合計ジャッジ時間 3,871 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
14,920 KB
testcase_01 AC 22 ms
14,940 KB
testcase_02 AC 23 ms
14,976 KB
testcase_03 AC 22 ms
14,932 KB
testcase_04 AC 23 ms
14,848 KB
testcase_05 AC 23 ms
14,952 KB
testcase_06 AC 23 ms
14,976 KB
testcase_07 AC 24 ms
14,772 KB
testcase_08 AC 23 ms
14,848 KB
testcase_09 AC 22 ms
14,848 KB
testcase_10 AC 23 ms
14,892 KB
testcase_11 AC 23 ms
14,976 KB
testcase_12 AC 22 ms
15,012 KB
testcase_13 AC 23 ms
14,772 KB
testcase_14 AC 23 ms
14,888 KB
testcase_15 AC 22 ms
14,932 KB
testcase_16 AC 23 ms
14,948 KB
testcase_17 AC 23 ms
14,932 KB
testcase_18 AC 23 ms
14,976 KB
testcase_19 AC 24 ms
14,956 KB
testcase_20 AC 23 ms
14,912 KB
testcase_21 AC 23 ms
14,976 KB
testcase_22 AC 24 ms
14,976 KB
testcase_23 AC 23 ms
14,892 KB
testcase_24 AC 22 ms
14,844 KB
testcase_25 AC 23 ms
14,976 KB
testcase_26 AC 23 ms
14,976 KB
testcase_27 AC 23 ms
14,900 KB
testcase_28 AC 22 ms
14,976 KB
testcase_29 AC 23 ms
14,848 KB
testcase_30 AC 23 ms
14,780 KB
testcase_31 AC 23 ms
14,848 KB
testcase_32 AC 23 ms
14,948 KB
testcase_33 AC 23 ms
14,772 KB
testcase_34 AC 24 ms
14,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 2 "cp-library/src/cp-template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull  = unsigned long long;
using i128 = __int128_t;
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }

#line 2 "cp-library/src/utility/rep_itr.hpp"
template < class T > struct itr {
    T i, d;
    constexpr itr(const T i) noexcept : i(i), d(1) {}
    constexpr itr(const T i, const T d) noexcept : i(i), d(d) {}
    void operator++() noexcept { i += d; }
    constexpr int operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept {
        return d > 0 ? i < x.i : i > x.i;
    }
};

template < class T > struct rep {
    const itr< T > s, t;
    constexpr rep(const T t) noexcept : s(0), t(t) {}
    constexpr rep(const T s, const T t) noexcept : s(s), t(t) {}
    constexpr rep(const T s, const T t, const T d) noexcept : s(s, d), t(t, d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end() const noexcept { return t; }
};

template < class T > struct revrep {
    const itr < T > s, t;
    constexpr revrep(const T t) noexcept : s(t - 1, -1), t(-1, -1) {}
    constexpr revrep(const T s, const T t) noexcept : s(t - 1, -1), t(s - 1, -1) {}
    constexpr revrep(const T s, const T t, const T d) noexcept : s(t - 1, -d), t(s - 1, -d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end() const noexcept { return t; }
};
#line 2 "cp-library/src/utility/io.hpp"
namespace scanner {
    struct sca {
        template < class T > operator T() {
            T s; cin >> s; return s;
        }
    };
    struct vec {
        int n;
        vec(int n) : n(n) {}
        template < class T > operator vector< T >() {
            vector< T > v(n);
            for(T& x : v) cin >> x;
            return v;
        }
    };
    struct mat {
        int h,w;
        mat(int h, int w) : h(h), w(w) {}
        template < class T > operator vector< vector< T > >() {
            vector m(h, vector< T >(w));
            for(vector< T >& v : m) for(T& x : v) cin >> x;
            return m;
        }
    };
    struct speedup {
        speedup() {
            cin.tie(0);
            ios::sync_with_stdio(0);
        }
    } su;
}
scanner::sca in() { return scanner::sca(); }
scanner::vec in(int n) { return scanner::vec(n); }
scanner::mat in(int h, int w) { return scanner::mat(h, w); }

namespace printer {
    void precision(int d) {
        cout << fixed << setprecision(d);
    }
    void flush() {
        cout.flush();
    }
}
int print() { cout << '\n'; return 0; }
template < class head, class... tail > int print(head&& h, tail&&... t) {
    cout << h; if(sizeof...(tail)) cout << ' ';
    return print(forward<tail>(t)...);
}
template < class T > int print(vector< T > a, char sep = ' ') {
    int n = a.size();
    for(int i : rep(n)) cout << a[i] << (i != n - 1 ? sep : '\n');
    return 0;
}
template < class T > int print(vector< vector< T > > a) {
    if(a.empty()) return 0;
    int h = a.size(), w = a[0].size();
    for(int i : rep(h)) for(int j : rep(w)) cout << a[i][j] << (j != w - 1 ? ' ' : '\n');
    return 0;
}
#line 2 "cp-library/src/utility/key_val.hpp"
template < class K, class V >
struct key_val {
    K key; V val;
    key_val() {}
    key_val(K key, V val) : key(key), val(val) {}
};
#line 2 "cp-library/src/utility/vec_op.hpp"
template < class T >
key_val< int, T > max_of(const vector< T >& a) {
    int i = max_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}

template < class T >
key_val< int, T > min_of(const vector< T >& a) {
    int i = min_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}

template < class T >
T sum_of(const vector< T >& a) {
    T sum = 0;
    for(const T x : a) sum += x;
    return sum;
}

template < class T >
vector<int> freq_of(const vector< T >& a, T L, T R) {
    vector<int> res(R - L);
    for(const T x : a) res[x - L]++;
    return res;
}

template < class T >
vector<int> freq_of(const vector< T >& a, T R) {
    return freq_of(a, T(0), R);
}

template < class T >
struct prefix_sum {
    vector< T > s;
    prefix_sum(const vector< T >& a) : s(a) {
        s.insert(s.begin(), T(0));
        for(int i : rep(a.size())) s[i + 1] += s[i];
    }
    // [L, R)
    T sum(int L, int R) {
        return s[R] - s[L];
    }
};
#line 2 "cp-library/src/number/modint.hpp"
struct modinfo { uint mod, root, isprime; };
template < modinfo const &ref >
struct modint {
    static constexpr uint const &mod = ref.mod;
    static constexpr uint const &root = ref.root;
    static constexpr uint const &isprime = ref.isprime;
    uint v = 0;
    constexpr modint& s(uint v) { this->v = v < mod ? v : v - mod; return *this; }
    constexpr modint(ll v = 0) { s(v % mod + mod); }
    modint operator-() const { return modint() - *this; }
    modint& operator+=(const modint& rhs) { return s(v + rhs.v); }
    modint& operator-=(const modint& rhs) { return s(v + mod - rhs.v); }
    modint& operator*=(const modint& rhs) { v = ull(v) * rhs.v % mod; return *this; }
    modint& operator/=(const modint& rhs) { return *this *= inv(rhs); }
    modint operator+(const modint& rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint& rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint& rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint& rhs) const { return modint(*this) /= rhs; }
    friend modint pow(modint x, ll n) { modint res(1); while(n > 0) { if(n & 1) res *= x; x *= x; n >>= 1; } return res; }
    friend modint inv(modint v) {
        if(isprime) {
            return pow(v, mod - 2);
        } else {
            ll a = v.v, b = modint::mod, x = 1, y = 0, t;
            while(b > 0) { t = a / b; swap(a -= t * b, b); swap(x -= t * y, y); }
            return modint(x);
        }
    }
    friend modint operator+(int x, const modint& y) { return modint(x) + y; }
    friend modint operator-(int x, const modint& y) { return modint(x) - y; }
    friend modint operator*(int x, const modint& y) { return modint(x) * y; }
    friend modint operator/(int x, const modint& y) { return modint(x) / y; }
    friend istream& operator>>(istream& is, modint& m) { ll x; is >> x; m = modint(x); return is; }
    friend ostream& operator<<(ostream& os, const modint& m) { return os << m.v; }
    bool operator==(const modint& r) const { return v == r.v; }
    bool operator!=(const modint& r) const { return v != r.v; }
    static uint get_mod() { return mod; }
};
constexpr modinfo base998244353 { 998244353, 3, 1 };
constexpr modinfo base1000000007 { 1000000007, 0, 1 };
using mint998244353 = modint< base998244353 >;
using mint1000000007 = modint< base1000000007 >;
#line 1 "cp-library/src/number/bicoef.hpp"
template < class mint >
class bicoef {
    int N;
    vector<mint> fact_, inv_, finv_;
  public:
    bicoef(int N) : N(N), fact_(N+1, 1), inv_(N+1, 1), finv_(N+1, 1) {
        uint mod = mint::get_mod();
        for(int i = 2; i <= N; i++) {
            fact_[i] = fact_[i - 1] * i;
            inv_ [i] = - inv_[mod % i] * (mod / i);
            finv_[i] = finv_[i - 1] * inv_[i];
        }
    }
    mint fact(int n) { assert(0 <= n && n <= N); return fact_[n]; }
    mint inv (int n) { assert(0 <= n && n <= N); return inv_ [n]; }
    mint finv(int n) { assert(0 <= n && n <= N); return finv_[n]; }
    mint comb(int n, int k) {
        if(k < 0 || n < k) return mint(0);
        return fact(n) * finv(k) * finv(n - k);
    }
    mint perm(int n, int k) { return fact(n) * finv(n - k); }
    mint homo(int n, int k) { return comb(n + k - 1, k); }
};
#line 4 "B.cpp"

int main() {
    int N = in(), M = in();
    using mint = mint998244353;
    bicoef<mint> coef(1e6);
    mint ans = 0;
    for(int i = 0; i <= M; i++) ans += coef.comb(i + i - 2, N - 1);
    print(ans);
}
0