結果

問題 No.2141 Enumeratest
ユーザー nyyanyya
提出日時 2022-12-02 22:03:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,411 bytes
コンパイル時間 3,978 ms
コンパイル使用メモリ 224,420 KB
実行使用メモリ 27,140 KB
最終ジャッジ日時 2024-04-18 06:05:46
合計ジャッジ時間 6,145 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
27,008 KB
testcase_01 AC 25 ms
27,008 KB
testcase_02 AC 24 ms
27,008 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 38 ms
26,844 KB
testcase_06 AC 26 ms
26,996 KB
testcase_07 AC 23 ms
26,880 KB
testcase_08 AC 24 ms
27,008 KB
testcase_09 AC 23 ms
26,884 KB
testcase_10 AC 24 ms
27,136 KB
testcase_11 AC 24 ms
27,136 KB
testcase_12 AC 23 ms
27,136 KB
testcase_13 AC 25 ms
26,984 KB
testcase_14 AC 24 ms
26,900 KB
testcase_15 AC 25 ms
27,008 KB
testcase_16 AC 24 ms
26,964 KB
testcase_17 AC 33 ms
27,056 KB
testcase_18 AC 38 ms
27,008 KB
testcase_19 AC 39 ms
27,008 KB
testcase_20 AC 36 ms
27,084 KB
testcase_21 AC 38 ms
27,008 KB
testcase_22 AC 31 ms
26,876 KB
testcase_23 AC 27 ms
26,880 KB
testcase_24 AC 28 ms
27,008 KB
testcase_25 AC 24 ms
27,136 KB
testcase_26 AC 34 ms
27,008 KB
testcase_27 AC 33 ms
26,888 KB
testcase_28 AC 38 ms
27,036 KB
testcase_29 AC 31 ms
26,880 KB
testcase_30 AC 37 ms
27,008 KB
testcase_31 AC 33 ms
26,880 KB
testcase_32 AC 33 ms
26,992 KB
testcase_33 AC 31 ms
27,000 KB
testcase_34 AC 32 ms
26,880 KB
testcase_35 AC 25 ms
27,008 KB
testcase_36 AC 37 ms
27,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
//using mint = modint;
using mint = modint998244353;
using P = pair<int, int>;

const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template <typename T> inline bool chmin(T& a,const T&b) {if(a>b){a=b; return 1;} return 0;}
template <typename T> inline bool chmax(T& a,const T&b) {if(a<b){a=b; return 1;} return 0;}

const int MAX = 1000000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

    int n,m;
    cin >> n >> m;

    COMinit();
    mint ans=1;
    int c=(m-1)/n;

    rep(i,n) {
        if((n-i)*c==m) {
            ans*=COM(m,c);
        } else {
            ans*=COM(m,c+1);
            m--;
        } 
        //cout << m  << " " << c << " " << ans.val()  << endl;
        m-=c;
    }
    cout << ans.val() << endl;

    return 0;
}
0