結果

問題 No.2141 Enumeratest
ユーザー T101010101T101010101
提出日時 2022-12-12 14:59:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 2,953 bytes
コンパイル時間 3,127 ms
コンパイル使用メモリ 254,000 KB
実行使用メモリ 19,564 KB
最終ジャッジ日時 2024-04-24 05:49:31
合計ジャッジ時間 7,613 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,008 KB
testcase_01 AC 10 ms
11,136 KB
testcase_02 AC 25 ms
11,392 KB
testcase_03 AC 9 ms
11,008 KB
testcase_04 AC 336 ms
19,564 KB
testcase_05 AC 68 ms
19,436 KB
testcase_06 AC 9 ms
11,088 KB
testcase_07 AC 10 ms
11,000 KB
testcase_08 AC 10 ms
11,104 KB
testcase_09 AC 12 ms
10,900 KB
testcase_10 AC 11 ms
11,008 KB
testcase_11 AC 10 ms
10,996 KB
testcase_12 AC 10 ms
11,156 KB
testcase_13 AC 10 ms
11,008 KB
testcase_14 AC 10 ms
11,016 KB
testcase_15 AC 11 ms
11,108 KB
testcase_16 AC 10 ms
11,132 KB
testcase_17 AC 201 ms
19,564 KB
testcase_18 AC 135 ms
19,436 KB
testcase_19 AC 273 ms
19,428 KB
testcase_20 AC 163 ms
19,424 KB
testcase_21 AC 175 ms
19,436 KB
testcase_22 AC 114 ms
19,320 KB
testcase_23 AC 92 ms
15,332 KB
testcase_24 AC 84 ms
13,284 KB
testcase_25 AC 15 ms
11,168 KB
testcase_26 AC 76 ms
19,556 KB
testcase_27 AC 143 ms
19,560 KB
testcase_28 AC 139 ms
19,564 KB
testcase_29 AC 88 ms
15,464 KB
testcase_30 AC 239 ms
19,560 KB
testcase_31 AC 170 ms
19,564 KB
testcase_32 AC 227 ms
19,560 KB
testcase_33 AC 149 ms
19,556 KB
testcase_34 AC 188 ms
19,560 KB
testcase_35 AC 27 ms
11,648 KB
testcase_36 AC 151 ms
19,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region Macros

#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
// using namespace __gnu_cxx;

#define TO_STRING(var) # var
#define pb emplace_back
#define int ll
#define endl '\n'

using ll = long long;
using ld = long double;
const ld PI = acos(-1);
const ld EPS = 1e-10;
const int INF = 1 << 30;
const ll INFL = 1LL << 62;
const int MOD = 998244353;
// const int MOD = 1000000007;

int ceil(int x, int y) {return (x > 0 ? (x + y - 1) / y : x / y);}
int POW(int x, int y) {
    if (y != (int)(y) or y < 0 or x != 0 && x != 1 && y > 64) {cout << "Error" << endl;return 0;}
    if (y == 0) return 1;
    if (y % 2 == 0) return POW(x * x, y / 2);
    return x * POW(x, y - 1);
}

__attribute__((constructor))
void constructor() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
}

#pragma endregion

template<int mod> class modint{
public:
    int val = 0;
    modint(int x = 0) { while (x < 0) x += mod; val = x % mod; }
    modint(const modint &r) { val = r.val; } // コピーコンストラクタ

    modint operator -(){ return modint(-val); } // 単項
    modint operator +(const modint &r) { return modint(*this) += r; }
    modint operator -(const modint &r) { return modint(*this) -= r; }
    modint operator *(const modint &r) { return modint(*this) *= r; }
    modint operator /(const modint &r) { return modint(*this) /= r; }

    modint &operator +=(const modint &r) {
        val += r.val;
        if (val >= mod) val -= mod;
        return *this;
    }
    modint &operator -=(const modint &r) {
        if (val < r.val) val += mod;
        val -= r.val;
        return *this;
    }
    modint &operator *=(const modint &r) {
        val = val * r.val % mod;
        return *this;
    }
    modint &operator /=(const modint &r) {
        int a = r.val, b = mod, u = 1, v = 0;
        while (b) {
            int t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % mod;
        if (val < 0) val += mod;
        return *this;
    }

    bool operator ==(const modint& r) { return this -> val == r.val; }
    bool operator <(const modint& r) { return this -> val < r.val; }
    bool operator !=(const modint& r) { return this -> val != r.val; }
};

using mint = modint<MOD>;

istream &operator >>(istream &is, mint& x) {
    int t; is >> t;
    x = t;
    return (is);
}
ostream &operator <<(ostream &os, const mint& x) {
    return os << x.val;
}

signed main() {
    int N, M;
	cin >> N >> M;
	int M2 = M;

	vector<mint> R(1e6 + 1);
    R[0] = 1;
    for (int i = 1; i <= 1e6; i++) {
        R[i] = R[i - 1] * i;
    }

	int d = M / N;
	M %= N;
	vector<int> A;
	for (int i = 0; i < N; i++) {
		A.pb(d + (M > 0));
		M--;
	}
	int sz = A.size();

	mint ans = 1;
	for (int i = 0; i < sz; i++) {
		mint chose = R[M2] / R[A[i]] / R[M2 - A[i]];
		M2 -= A[i];
		ans *= chose;
	}
	cout << ans << endl;
}
0