結果

問題 No.2141 Enumeratest
ユーザー hikaririhikariri
提出日時 2023-03-23 18:45:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 1,628 bytes
コンパイル時間 3,808 ms
コンパイル使用メモリ 229,720 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 19:35:20
合計ジャッジ時間 8,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 10 ms
4,348 KB
testcase_03 AC 12 ms
4,348 KB
testcase_04 AC 225 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 8 ms
4,348 KB
testcase_11 AC 11 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 11 ms
4,348 KB
testcase_15 AC 7 ms
4,348 KB
testcase_16 AC 8 ms
4,348 KB
testcase_17 AC 134 ms
4,348 KB
testcase_18 AC 63 ms
4,348 KB
testcase_19 AC 170 ms
4,348 KB
testcase_20 AC 94 ms
4,348 KB
testcase_21 AC 93 ms
4,348 KB
testcase_22 AC 60 ms
4,348 KB
testcase_23 AC 58 ms
4,348 KB
testcase_24 AC 52 ms
4,348 KB
testcase_25 AC 7 ms
4,348 KB
testcase_26 AC 10 ms
4,348 KB
testcase_27 AC 77 ms
4,348 KB
testcase_28 AC 66 ms
4,348 KB
testcase_29 AC 42 ms
4,348 KB
testcase_30 AC 157 ms
4,348 KB
testcase_31 AC 107 ms
4,348 KB
testcase_32 AC 148 ms
4,348 KB
testcase_33 AC 89 ms
4,348 KB
testcase_34 AC 126 ms
4,348 KB
testcase_35 AC 13 ms
4,348 KB
testcase_36 AC 79 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
#endif
typedef long long  ll;
typedef pair<int,int> pii; typedef pair<ll,ll> pll;
const int INF = 1e9; const long long LINF = 1e18;
const int MOD = 998244353; const int MOD1 = 1e9+7;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(x) x.begin(), x.end()
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
void yorn(bool ans){cout << (ans?"Yes":"No") << endl; return;}

ll power(ll a, ll b, ll m){
    ll ans = 1, p = a;
    rep(i,50){
        ll wari = (1LL<<i);
        if((b/wari)%2==1) ans = ans*p%m;
        p = p*p%m;
    }
    return ans;
}

// しばらくはsize_tをキャストに任せてみようかな
int main(){
    ll n,m; cin >> n >> m;
    ll a = m/n;
    ll b = m%n; // a+1個
    ll c = n-b; // a個
    ll ans = 1;
    ll mm = m;
    // mmCa+1
    rep(k,b){
        rep(j,a+1){
            ans = ans*mm%MOD;
            mm--;
        }
        ll bumbo = 1;
        for(int i=1;i<=a+1;i++){
            bumbo = bumbo*i%MOD;
        }
        ans = ans*power(bumbo,MOD-2,MOD)%MOD;
    }
    if(a!=0){
        rep(i,c){
            rep(j,a){
                ans = ans*mm%MOD;
                mm--;
            }
            ll bumbo = 1;
            for(int k=1;k<=a;k++){
                bumbo = bumbo*k%MOD;
            }
            ans = ans*power(bumbo,MOD-2,MOD)%MOD;
        }
    }
    cout << ans << endl;

}
0