結果

問題 No.1388 Less than K
コンテスト
ユーザー vjudge1
提出日時 2026-04-11 12:49:29
言語 C
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 56 ms / 3,000 ms
コード長 921 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 161 ms
コンパイル使用メモリ 39,348 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-11 12:49:36
合計ジャッジ時間 6,148 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 74
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
const int mod = 998244353;
int h, w, k, f[400010], ff[400010], ans;
int ksm(int a, int b) {
    int ans = 1;
    while (b) {
        if (b & 1) ans = 1ll * ans * a % mod;
        b >>= 1;
        a = 1ll * a * a % mod;
    }
    return ans;
}
int C(int x, int y) { return x < y ? 0 : 1ll * f[x] * ff[y] % mod * ff[x - y] % mod; }
int calc(int x, int y) { return 1ll * C(w, (w - x - y) / 2) * C(w, (w - x + y) / 2) % mod; }
void init() {
    if (h > w) h ^= w ^= h ^= w;
    w += h, h = w - h - h;
}
int main() {
    scanf("%d %d %d", &h, &w, &k), h--, w--, k >>= 1, f[0] = ff[0] = 1, init();
    for (int i = 1; i <= 400005; i++) f[i] = 1ll * i * f[i - 1] % mod, ff[i] = ksm(f[i], mod - 2);
    for (int i = 1; i * 2 * (k + 1) + h <= w; i++) ans = (ans + (i & 1 ? mod - calc(h, i * 2 * (k + 1)) : calc(h, i * 2 * (k + 1)))) % mod;
    printf("%d", (ans * 2ll % mod + calc(0, h)) % mod);
    return 0;
}
0