結果

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

テストケース

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

ソースコード

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;

    if(n>m) {
        cout << COM(n,m) << endl;
        return 0;
    }

    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