結果

問題 No.1520 Zigzag Sum
ユーザー hir355hir355
提出日時 2021-05-28 21:23:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 81,712 KB
最終ジャッジ日時 2023-08-07 05:28:54
合計ジャッジ時間 3,955 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
78,712 KB
testcase_01 AC 79 ms
78,788 KB
testcase_02 AC 358 ms
81,464 KB
testcase_03 AC 423 ms
81,688 KB
testcase_04 AC 428 ms
81,620 KB
testcase_05 AC 423 ms
81,616 KB
testcase_06 AC 402 ms
81,712 KB
testcase_07 AC 405 ms
81,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
fac = [1] * (4 * 10 ** 5 + 10)
for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD
t = int(input())
for _ in range(t):
    h, w = map(int, input().split())
    if h == 1 or w == 1:
        print(0)
    else:
        print(fac[h + w - 3] * pow(fac[h - 2] * fac[w - 2], MOD - 2, MOD) * 2 % MOD)
0