結果

問題 No.1520 Zigzag Sum
ユーザー googol_S0googol_S0
提出日時 2021-05-28 20:56:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 611 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 246,272 KB
最終ジャッジ日時 2024-04-24 23:13:25
合計ジャッジ時間 5,585 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 316 ms
246,272 KB
testcase_01 AC 318 ms
246,144 KB
testcase_02 AC 575 ms
246,144 KB
testcase_03 AC 591 ms
246,144 KB
testcase_04 AC 602 ms
246,272 KB
testcase_05 AC 611 ms
246,144 KB
testcase_06 AC 597 ms
246,144 KB
testcase_07 AC 587 ms
246,272 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