結果

問題 No.2141 Enumeratest
ユーザー shinchanshinchan
提出日時 2022-12-02 23:20:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 400 ms / 2,000 ms
コード長 2,290 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 199,076 KB
実行使用メモリ 50,544 KB
最終ジャッジ日時 2024-04-18 08:36:22
合計ジャッジ時間 9,623 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
50,404 KB
testcase_01 AC 63 ms
50,244 KB
testcase_02 AC 80 ms
50,500 KB
testcase_03 AC 66 ms
50,448 KB
testcase_04 AC 331 ms
50,316 KB
testcase_05 AC 326 ms
50,336 KB
testcase_06 AC 63 ms
50,244 KB
testcase_07 AC 72 ms
50,508 KB
testcase_08 AC 75 ms
50,452 KB
testcase_09 AC 68 ms
50,284 KB
testcase_10 AC 68 ms
50,344 KB
testcase_11 AC 76 ms
50,208 KB
testcase_12 AC 74 ms
50,204 KB
testcase_13 AC 76 ms
50,348 KB
testcase_14 AC 59 ms
50,360 KB
testcase_15 AC 60 ms
50,256 KB
testcase_16 AC 58 ms
50,240 KB
testcase_17 AC 219 ms
50,340 KB
testcase_18 AC 278 ms
50,348 KB
testcase_19 AC 331 ms
50,304 KB
testcase_20 AC 256 ms
50,288 KB
testcase_21 AC 272 ms
50,372 KB
testcase_22 AC 229 ms
50,356 KB
testcase_23 AC 163 ms
50,500 KB
testcase_24 AC 117 ms
50,544 KB
testcase_25 AC 74 ms
50,352 KB
testcase_26 AC 311 ms
50,244 KB
testcase_27 AC 276 ms
50,396 KB
testcase_28 AC 347 ms
50,304 KB
testcase_29 AC 200 ms
50,476 KB
testcase_30 AC 400 ms
50,336 KB
testcase_31 AC 236 ms
50,176 KB
testcase_32 AC 239 ms
50,428 KB
testcase_33 AC 220 ms
50,496 KB
testcase_34 AC 200 ms
50,300 KB
testcase_35 AC 92 ms
50,312 KB
testcase_36 AC 299 ms
50,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

const ll N = 2000007;
ll fac[N],finv[N],inv[N];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N;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;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

ll COM(ll n, ll k){
    if(n < k or n < 0 or k < 0) return 0;
    k = min(n - k, k);
    ll ret = finv[k]; // for() modpow(a, mod - 2);
    for(ll r=n-k+1;r<=n;r++){
        ret *= r;
        ret %= mod;
    }
    return ret;
}



struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if(t < 0) return mint(1) / pow(-t);
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false); 

    cominit();
    ll n, m;
    cin >> n >> m;
    ll d = m / n;
    ll p = m % n;
    mint ans = mint(fac[m]);
    for(ll i = 0; i < n; i ++) {
        if(i < p) ans /= mint(fac[d + 1]);
        else ans /= mint(fac[d]);
    }
    cout <<ans.x << endl;
    return 0;
}
0