結果

問題 No.2023 Tiling is Fun
ユーザー yamakeyamake
提出日時 2022-07-29 21:58:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,624 bytes
コンパイル時間 4,096 ms
コンパイル使用メモリ 228,048 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 20:50:20
合計ジャッジ時間 5,099 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<"\n";
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1.1e18;const int inf=1.01e9;
constexpr int MOD=1000000007;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }

#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;

template<class T>
struct Binom{
    long long n;
    bool flag=false;
    vector<T> kaijo,inv_kaijo;
    Binom(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i));
        }
    }
    void invList(){
      inv_kaijo.push_back(1);
      flag=true;
      for(int i=1;i<=n;++i){
        inv_kaijo.push_back(1/kaijo[i]);
      }
    }
    T binom(long long N,long long K){
        if(N<0||K<0)return 0;
        if(N<K)return 0;
        if(flag)return kaijo[N]*inv_kaijo[K]*inv_kaijo[N-K];
        T res=kaijo[N]/kaijo[K];//
        res/=kaijo[N-K];
        return res;
    }
    T binom2(mint N,long long K){
        // O(K)で2項係数を返す
        T res=1/kaijo[K];
        for(long long i=0;i<K;++i){
            res*=(N-i);
        }
        return res;
    }
};

signed main(){
    int a,b;cin>>a>>b;
    Binom<mint> binom(a+b+10);
    cout<<binom.binom(a+b-2,a-1).val()<<"\n";
    return 0;
}
0