結果

問題 No.2511 Mountain Sequence
ユーザー maeshunmaeshun
提出日時 2023-10-21 09:56:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 3,140 bytes
コンパイル時間 3,984 ms
コンパイル使用メモリ 233,316 KB
実行使用メモリ 8,012 KB
最終ジャッジ日時 2023-10-21 09:56:43
合計ジャッジ時間 5,392 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 11 ms
6,228 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 5 ms
4,724 KB
testcase_05 AC 7 ms
5,260 KB
testcase_06 AC 10 ms
6,224 KB
testcase_07 AC 10 ms
6,684 KB
testcase_08 AC 4 ms
4,476 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 12 ms
6,700 KB
testcase_11 AC 16 ms
7,908 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 12 ms
6,860 KB
testcase_14 AC 15 ms
8,012 KB
testcase_15 AC 15 ms
7,940 KB
testcase_16 AC 17 ms
7,840 KB
testcase_17 AC 13 ms
6,996 KB
testcase_18 AC 11 ms
6,708 KB
testcase_19 AC 12 ms
6,788 KB
testcase_20 AC 12 ms
6,956 KB
testcase_21 AC 13 ms
6,956 KB
testcase_22 AC 13 ms
6,668 KB
testcase_23 AC 7 ms
4,888 KB
testcase_24 AC 8 ms
5,416 KB
testcase_25 AC 16 ms
7,984 KB
testcase_26 AC 5 ms
4,624 KB
testcase_27 AC 10 ms
6,184 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 11 ms
6,980 KB
testcase_30 AC 11 ms
6,916 KB
testcase_31 AC 12 ms
6,940 KB
testcase_32 AC 12 ms
6,860 KB
testcase_33 AC 15 ms
7,908 KB
testcase_34 AC 12 ms
6,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

// combination mod prime
// https://youtu.be/8uowVvQ_-Mo?t=6002
// https://youtu.be/Tgd_zLfRZOQ?t=9928
struct modinv {
  int n; vector<mint> d;
  modinv(): n(2), d({0,1}) {}
  mint operator()(int i) {
    while (n <= i) d.push_back(-d[mint::mod()%n]*(mint::mod()/n)), ++n;
    return d[i];
  }
  mint operator[](int i) const { return d[i];}
} invs;
struct modfact {
  int n; vector<mint> d;
  modfact(): n(2), d({1,1}) {}
  mint operator()(int i) {
    while (n <= i) d.push_back(d.back()*n), ++n;
    return d[i];
  }
  mint operator[](int i) const { return d[i];}
} facts;
struct modfactinv {
  int n; vector<mint> d;
  modfactinv(): n(2), d({1,1}) {}
  mint operator()(int i) {
    while (n <= i) d.push_back(d.back()*invs(n)), ++n;
    return d[i];
  }
  mint operator[](int i) const { return d[i];}
} ifacts;
mint comb(int n, int k) {
  if (n < k || k < 0) return 0;
  return facts(n)*ifacts(k)*ifacts(n-k);
}

uint64_t combinations2(uint64_t n, uint64_t k) {
    uint64_t r = 1;
    for (uint64_t d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

// vector<vector<mint>> comb(n+1, vector<mint>(n+1));
// rep(i,n+1) comb[i][0] = 1;
// for(int i=1;i<=n;i++){
//     for(int j=1;j<=n;j++){
//         comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
//     }
// }

//Lucasの定理(素数mod)
/* Com:nCk % p の計算のための構造体
    前処理・初期化: O(p^2)
    nCk(n,k): nCk % p の計算。O(log n)
*/
// struct Comb {
//     vector<vector<long long>> com;  // 前計算の結果を保存
//     long long p;                    // p は素数である必要がある
//     Comb(long long _p) : p(_p) {
//         init(p);
//     }
//     void init(long long p) {  // 動的計画法で前処理
//         com.assign(p, vector<long long>(p));
//         com[0][0] = 1;
//         for (int i = 1; i < p; i++) {
//             com[i][0] = 1;
//             for (int j = i; j > 0; j--) {
//                 com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]) % p;
//             }
//         }
//     }
//     long long nCk(long long n, long long k) {
//         long long ret = 1;
//         while (n > 0) {  // 下から一桁ずつ計算する
//             int ni = n % p;
//             int ki = k % p;
//             ret *= com[ni][ki];
//             ret %= p;
//             n /= p;
//             k /= p;
//         }
//         return ret;
//     }
// };

int main()
{
    int n, m;
    cin >> n >> m;
    mint ans = 0;
    for(int j=1;j<=m;j++){
      ans += comb(2*j-2,n-1);
    }

    cout << ans.val() << endl;
    return 0;
}
0