結果

問題 No.1520 Zigzag Sum
ユーザー hir355hir355
提出日時 2021-05-28 21:23:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 371 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 80,640 KB
最終ジャッジ日時 2024-04-24 23:38:22
合計ジャッジ時間 3,218 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
60,928 KB
testcase_01 AC 46 ms
60,928 KB
testcase_02 AC 262 ms
79,232 KB
testcase_03 AC 371 ms
80,640 KB
testcase_04 AC 370 ms
80,512 KB
testcase_05 AC 369 ms
80,384 KB
testcase_06 AC 360 ms
80,384 KB
testcase_07 AC 355 ms
79,872 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