結果

問題 No.1186 長方形の敷き詰め
ユーザー ぷらぷら
提出日時 2020-08-22 18:03:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 916 bytes
コンパイル時間 1,378 ms
コンパイル使用メモリ 163,228 KB
実行使用メモリ 27,172 KB
最終ジャッジ日時 2024-04-23 11:55:42
合計ジャッジ時間 4,060 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
26,868 KB
testcase_01 AC 67 ms
26,948 KB
testcase_02 AC 68 ms
27,024 KB
testcase_03 AC 69 ms
27,020 KB
testcase_04 AC 69 ms
26,972 KB
testcase_05 AC 68 ms
27,008 KB
testcase_06 AC 68 ms
26,956 KB
testcase_07 AC 69 ms
26,856 KB
testcase_08 AC 68 ms
26,972 KB
testcase_09 AC 69 ms
26,972 KB
testcase_10 AC 69 ms
26,972 KB
testcase_11 AC 69 ms
27,004 KB
testcase_12 AC 68 ms
26,976 KB
testcase_13 AC 69 ms
26,840 KB
testcase_14 AC 68 ms
27,072 KB
testcase_15 AC 68 ms
26,896 KB
testcase_16 AC 71 ms
26,892 KB
testcase_17 AC 68 ms
26,872 KB
testcase_18 AC 67 ms
27,032 KB
testcase_19 AC 68 ms
26,908 KB
testcase_20 AC 69 ms
27,064 KB
testcase_21 AC 69 ms
27,160 KB
testcase_22 AC 85 ms
26,960 KB
testcase_23 AC 69 ms
27,044 KB
testcase_24 AC 70 ms
26,976 KB
testcase_25 AC 71 ms
27,172 KB
testcase_26 AC 68 ms
26,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int fac[1000005], finv[1000005], inv[1000005];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000005; 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;
    }
}
int 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;
}
signed main() {
    COMinit();
    int N,M;
    cin >> N >> M;
    int ans = 1;
    if(N == 1) {
        cout << 1 << endl;
        return 0;
    }
    for(int i = 1; i <= M/N; i++) {
        ans += COM(M-N*i+i,i);
        ans %= mod;
    }
    cout << ans%mod << endl;
}
0