結果

問題 No.1520 Zigzag Sum
ユーザー googol_S0googol_S0
提出日時 2021-05-28 20:56:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 552 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 259,476 KB
最終ジャッジ日時 2023-08-07 05:01:04
合計ジャッジ時間 5,227 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 264 ms
259,304 KB
testcase_01 AC 265 ms
259,460 KB
testcase_02 AC 532 ms
259,388 KB
testcase_03 AC 550 ms
259,192 KB
testcase_04 AC 550 ms
259,476 KB
testcase_05 AC 552 ms
259,464 KB
testcase_06 AC 518 ms
259,364 KB
testcase_07 AC 530 ms
259,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
def cmb(n,r):
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod

g1=[1,1]
g2=[1,1]
inv=[0,1]
for i in range(2,1000003):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)

for t in range(int(input())):
  H,W=map(int,input().split())
  print(2*(H-1)*min(1,W-1)*g1[H+W-3]*g2[W-2]*g2[H-1]%mod)
0