結果

問題 No.1186 長方形の敷き詰め
ユーザー cromcrom
提出日時 2020-08-22 13:49:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,077 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 164,896 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-04-23 08:13:59
合計ジャッジ時間 2,962 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
26,796 KB
testcase_01 AC 27 ms
26,752 KB
testcase_02 AC 30 ms
26,752 KB
testcase_03 AC 27 ms
26,880 KB
testcase_04 AC 28 ms
26,772 KB
testcase_05 AC 30 ms
26,752 KB
testcase_06 AC 27 ms
26,784 KB
testcase_07 AC 28 ms
26,684 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 29 ms
26,752 KB
testcase_12 AC 30 ms
26,732 KB
testcase_13 AC 27 ms
26,792 KB
testcase_14 AC 27 ms
26,752 KB
testcase_15 AC 28 ms
26,740 KB
testcase_16 AC 30 ms
26,752 KB
testcase_17 AC 30 ms
26,800 KB
testcase_18 AC 30 ms
26,860 KB
testcase_19 AC 30 ms
26,740 KB
testcase_20 AC 31 ms
26,624 KB
testcase_21 AC 28 ms
26,624 KB
testcase_22 AC 35 ms
26,752 KB
testcase_23 AC 30 ms
26,880 KB
testcase_24 AC 31 ms
26,856 KB
testcase_25 AC 30 ms
26,760 KB
testcase_26 AC 28 ms
26,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 998244353;
static const int SIZE = 1000005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < SIZE; ++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 comb(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;

}

// 二項係数
LL Bin(LL n, LL k) {
    if(k < 0 || n < k) {
        return 0;

    }
    LL ret = 1;
    for(LL i = 1; i <= k; ++i) {
        ret *= n--;
        ret /= i;

    }
    return ret;
}

// 重複組み合わせ
LL comb_rep(int x, int y) {
    return comb(x + y - 1, x - 1);

}

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

    int N, M;
    cin >> N >> M;

    combInit();

    LL res = 0;
    for(int i = 0; i <= M; ++i) {
        if((M - i) % N != 0) continue;
        res = (res + comb(i + (M - i) / N, i)) % MOD;
        //res = (res + comb_rep(i, (M - i) / N)) % MOD;
    }
    cout << res << endl;

    return 0;
}

0