結果

問題 No.1186 長方形の敷き詰め
ユーザー ぷらぷら
提出日時 2020-08-22 17:59:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 824 bytes
コンパイル時間 1,890 ms
コンパイル使用メモリ 162,940 KB
実行使用メモリ 27,136 KB
最終ジャッジ日時 2024-04-23 11:55:04
合計ジャッジ時間 5,282 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
26,996 KB
testcase_01 AC 101 ms
26,880 KB
testcase_02 AC 94 ms
26,880 KB
testcase_03 AC 97 ms
26,976 KB
testcase_04 AC 97 ms
27,136 KB
testcase_05 AC 102 ms
27,008 KB
testcase_06 AC 98 ms
27,008 KB
testcase_07 AC 99 ms
26,880 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 100 ms
26,988 KB
testcase_12 AC 101 ms
27,008 KB
testcase_13 AC 93 ms
27,072 KB
testcase_14 AC 98 ms
26,880 KB
testcase_15 AC 90 ms
27,008 KB
testcase_16 AC 102 ms
26,952 KB
testcase_17 AC 95 ms
27,008 KB
testcase_18 AC 92 ms
27,116 KB
testcase_19 AC 108 ms
27,032 KB
testcase_20 AC 94 ms
27,008 KB
testcase_21 AC 98 ms
27,008 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 99 ms
27,128 KB
testcase_25 AC 94 ms
26,880 KB
testcase_26 AC 99 ms
27,136 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;
    for(int i = 1; i <= M/N; i++) {
        ans += COM(M-N*i+i,i);
    }
    cout << ans << endl;
}
0