submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s679471288 | p04046 | Time Limit Exceeded | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S():... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s127325022 | p04046 | Time Limit Exceeded | import math
def solve(H, W, A, B):
ans = 0
R = 10 ** 9 + 7
p1_y = math.factorial(H - 1 - A)
d2_y = math.factorial(H - 1 - (H - A))
way1 = -1
way3 = -1
for i in range(0, W - B):
p1 = (B + i, H - 1 - A)
p2 = (B + i, H - A)
e = (W - 1, H - 1)
d2 = (e[0] - p2[... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s422788859 | p04046 | Time Limit Exceeded | import math
def solve(H, W, A, B):
ans = 0
R = 10 ** 9 + 7
p1_y = math.factorial(H - 1 - A)
d2_y = math.factorial(H - 1 - (H - A))
way1 = -1
way3 = -1
for i in range(0, W - B):
p1 = (B + i, H - 1 - A)
p2 = (B + i, H - A)
e = (W - 1, H - 1)
d2 = (e[0] - p2[0... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s930978160 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
fac = [1 for _ in range(10**6+1)]
for i in range(1, 10 **6):
fac[i+1] = fac[i] * (i + 1)
def combination(n, r):
result = fac[n] // (fac[r] * fac[n-r])
return result
for i in range(B, W):
ans += (combination(H - A - 1 + i, i) * combinatio... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s357248653 | p04046 | Time Limit Exceeded | H,W,A,B=map(int,input().split())
power=[]
for tate in range(H):
x= []
for yoko in range(W):
x.append(0)
power.append(x)
power[0][0]+=1
def calc(power,x,y):
if y==0 and x==0:return power
if y==0:ue=0
if y!=0:ue=power[y-1][x]
if x==0:hidari=0
if x!=0:hidari=power[y][x-1]
if y>=... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s674042913 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for k in range(1, H + W):
for y in range(max(H, W)):
x = k - y
if 0 <= y < H and 0 <= x < W:
if y < H - A or B <= x:
if x - 1 >= 0:
dp[y][x] += dp[y][x - 1]
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s076405041 | p04046 | Time Limit Exceeded | import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
H,W,A,B=map(int,raw_input().split())
Corner=[[B+i,A+i] for i in range(1,min(W-B,H-A)+1)]
Result=0
for c in Corner:
Result+=combinations_count(c[0]-1+H-c[1],c[0]-1)*combinations_count(W-c[... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s969022599 | p04046 | Time Limit Exceeded | # calculate N!(modP)
def fac(n):
ans = 1
mod = 10**9+7
for i in range(1, n+1):
ans *= i
ans %= mod
return ans
# calculate a**b(modP)
def cal(a, b, mod):
if b == 0:
return 1
elif b % 2 == 0:
return cal(a, b//2, mod)**2 % mod
else:
return (a * cal... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s972090134 | p04046 | Time Limit Exceeded | K = 10 ** 9 + 7
def pow_K(x, n):
if n == 0:
return 1
else:
return (pow_K(x, n // 2) ** 2 * x ** (n % 2)) % K
H, W, A, B = map(int, input().split())
fact = [0 for i in range(H+W-1)]
fact[0] = 1
for i in range(H+W-2):
fact[i + 1] = fact[i] * (i+1) % K
fact_inv = [pow_K(fact[i], K-2) for i in range(H+W-1)... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s428777035 | p04046 | Time Limit Exceeded | from math import factorial
def P(n, r):
return factorial(n)//factorial(n-r)
def C(n, r):
return P(n, r)//factorial(r)
ans = 0
H,W,A,B = map(int, input().split())
MOD = int(1e9)+7
for i in range(min(H-A, W-B)):
ans += C(H-A+B-1, B+i)*C(A+W-B-1, A+i)
# print(ans)
ans %= MOD
print(ans) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s249800657 | p04046 | Time Limit Exceeded | # -*- coding: utf-8 -*-
import math
H, W, A, B = map(int, input().split())
union_sum = 0
i = 0
for n in range(B, W):
m = H - A - 1 + n
tmp_a = math.factorial(m) // (math.factorial(n) * math.factorial(m - n))
tmp_b = math.factorial(A - B + W - 2 - i) // (math.factorial(A - 1) * math.factorial(W - B - 1 - ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s694235800 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int, input().split())
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def solve():
ans = 0
an = H + B - A - 1
ar = B
bn = W + A - B - 2
br = W - B - 1
for i in range(W-B):
a = comb(an, ar)
b = comb(bn, br... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s765871833 | p04046 | Time Limit Exceeded | iH,iW,iA,iB = [int(x) for x in input().split()]
iD = 1000000007
def fFr(iX,iR=1):
if iR == 0 or iX == 0:
return 1
else :
iRet = 1
for i in range(iR,iX+1):
iRet *= i
return iRet
def fnCr(iN,iR):
if iR == 0:
return 1
else:
return fFr(iN,iR+1) /... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s087266082 | p04046 | Time Limit Exceeded | # -*- coding: utf-8 -*-
H,W,A,B = map(int, input().split())
# 予め組み合わせ計算に必要な階乗のテーブルを作っておく
factorials = [0] * (H+W)
factorials[0] = 1
factorials[1] = 1
for i in range(2,H+W):
factorials[i] = factorials[i-1] * i
# 組み合わせの数だけ返してくれる関数(自作)
def nCr(n, r):
# 10C7 = 10C3
r = min(r, n-r)
# 分子の計算
numerat... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s927010735 | p04046 | Time Limit Exceeded | # -*- coding: utf-8 -*-
# 組み合わせの数だけ返してくれる関数
def nCr(n, r):
"""
Calculate the number of combination (nCr = nPr/r!).
The parameters need to meet the condition of n >= r >= 0.
It returns 1 if r == 0, which means there is one pattern
to choice 0 items out of the number of n.
"""
# 10C7 = 10C3
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s888458636 | p04046 | Time Limit Exceeded | # -*- coding: utf-8 -*-
from itertools import combinations as comb
H,W,A,B = map(int, input().split())
h = H - A
w = B + 1
ans = 0
# マスを右上に1つずつずらして、必ず通る場所でパターンを足し合わせていく
while h > 0 and w <= W:
ans += len(list(comb([0] * (h+w-2), h-1))) * len(list(comb([0] * (H-h+W-w), H-h))) % (10 ** 9 + 7)
h -= 1
w += 1... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s964365035 | p04046 | Time Limit Exceeded | # -*- coding: utf-8 -*-
from itertools import combinations as comb
H,W,A,B = map(int, input().split())
HW = len(list(comb([0] * (H+W-2), H-1)))
h = H - A
w = B + 1
ans = 0
# マスを右上に1つずつずらして、必ず通る場所でパターンを足し合わせていく
while h > 0 and w <= W:
ans += len(list(comb([0] * (h+w-2), h-1))) * len(list(comb([0] * (H-h+W-w), H-... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s258874669 | p04046 | Time Limit Exceeded | from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())
H,W,A,B=inpl()
ans = 0
def Comb(n,k):#nCk
gya... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s733825296 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
m = 10**9 + 7
fc = [1] * (H + W)
for i in range(2, H+W):
fc[i] = fc[i - 1] * i % m
def mod_pow(x, n, mod):
if n == 0: return 1
d, m = n >> 1, n & 1
p = mod_pow(x, d, mod)
return (p * p * (x if m else 1)) % mod
def rev(c, r):
return mod_pow(fc[c] * fc[r]... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s953924166 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
m = 10**9 + 7
fc = [1] * (H + W)
for i in range(2, H+W):
fc[i] = fc[i - 1] * i % m
def mod_pow(x, n, mod):
if n == 0: return 1
d, m = n >> 1, n & 1
p = mod_pow(x, d, mod)
return (p * p * (x if m else 1)) % mod
import functools
@functools.lru_cache(maxsize=N... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s914249857 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
m = 10**9 + 7
fc = [1] * (H + W)
for i in range(2, H+W):
fc[i] = fc[i - 1] * i % m
def mod_pow(x, n, mod):
if n == 0: return 1
d, m = n >> 1, n & 1
p = mod_pow(x, d, mod)
return (p * p * (x if m else 1)) % mod
def rev(n):
return mod_pow(n, m - 2, m)
de... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s393173368 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
m = 10**9 + 7
fc = [1] * (H + W)
for i in range(2, H+W):
fc[i] = fc[i - 1] * i % m
import functools
@functools.lru_cache(maxsize=None)
def fact(n):
if n == 0: return 1
return n * fc[n - 1] % m
def mod_pow(x, n, mod):
if n == 0: return 1
d, m = n >> 1, n & 1... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s709974015 | p04046 | Time Limit Exceeded | H, W, A, B = map(int,input().split())
P = 10**9+7
#H, W, A, B = map(int,"100000 100000 44444 55555".split())
factlist = [1] * (H+W)
t = 1
for i in range(H+W-1):
t = (t * (i+1)) % P
factlist[i+1] = t
def fact(i):
return factlist[i]
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x =... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s890874524 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int, input().split())
p = 10 ** 9 + 7
ans = 0
def fac(a, b):
a = math.factorial(a + b) // math.factorial(a) // math.factorial(b)
return a % p
for h in range(H - A):
ans += fac(h, B - 1) * fac(H - h - 1, W - B - 1) % p
print(ans % p) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s550366751 | p04046 | Time Limit Exceeded | # E.py#
H, W, A, B = map(int,input().split())
P = 10**9+7
# H, W, A, B = map(int,"2 3 1 1".split())
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)
def modinv(a, m):
g, x, y = egcd(a, m)
if g != 1:
raise Excepti... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s305468610 | p04046 | Time Limit Exceeded | MOD = 10**9+7
from math import factorial
h, w, a, b = list(map(int, input().split()))
num_path = 0
def get_path(n, r):
return factorial(n)//(factorial(n-r)*factorial(r))
y, x = h-a, b+1
while(True):
path_0 = get_path((y+x-2), min(x-1, y-1))
path_1 = get_path((h-y+w-x), min(h-y, w-x))
# print(y, x, pat... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s249540129 | p04046 | Time Limit Exceeded | h, w, lower_bound, left_bound = map(int, input().split())
grid = [[0 for i in range(w)] for j in range(h)]
lower_i = h - lower_bound
left_i = left_bound
for i in range(lower_i, len(grid)):
for j in range(0, left_i):
grid[i][j] = 1
def count_path(row, col, grid, memo):
if memo[row][col] != -1:
return mem... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s061149940 | p04046 | Time Limit Exceeded | import itertools
H,W,A,B = map(int, input().split())
ans = 0
for i in range(H-A):
L1 = [j for j in range(B+i-1)]
L2 = [k for k in range(H+W-B-i-2)]
C1 = list(itertools.combinations(L1,i))
C2 = list(itertools.combinations(L2,W-B-1))
ans += (len(C1) * len(C2)) %(10**9 + 7)
print(ans) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s446506129 | p04046 | Time Limit Exceeded | LIM = 10**9 + 7
def main():
h, w, a, b = map(int, input().split())
print(solve(h, w, a, b))
def solve(h, w, a, b):
ans = 0
for i in range(h-a):
first = n_noblock_fast(i + 1, b) % LIM
second = n_noblock_fast(w - b, h - i) % LIM
ans = (ans + (first * second) % LIM) % LIM
r... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s919843366 | p04046 | Time Limit Exceeded | h,w,a,b=list(map(int,input().split()))
road=[[0 for i in range(w)] for j in range(h)]
road[0][0]=1
for i in range(h):
for j in range(w):
if i>h-a-1 and j<b:
continue
if i-1>=0:
road[i][j]+=road[i-1][j]
if j-1>=0:
if i>h-a-1 and j==b:
conti... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s065994351 | p04046 | Time Limit Exceeded | MOD = 10**9+7
l = list(map(int,input().split()))
h,w,a,b = l[0],l[1],l[2],l[3]
def pow(x,n):
res = 1
while n > 0:
if n % 2 == 1:
res = res*x % MOD
x = x*x % MOD
n = n >> 1
return res
def comb(n,k):
return (fact[n]*inv[k] % MOD)*inv[n-k] % MOD
fact = [1]
inv = [1]
fo... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s429004966 | p04046 | Time Limit Exceeded | import math
M = 10**9+7
def nCr(n, r):
return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
h, w, a, b = map(int, input().split())
ans = 0
for i in range(b,w):
ans += nCr(h-a-1+i,h-a-1) * nCr(a-1+w-1-i, a-1)
print(ans % M)
| 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s858913931 | p04046 | Time Limit Exceeded | import scipy.misc as scm
h, w, a, b = [int(i) for i in input().split()]
p = 10 ** 9 + 7
s = 0
for i in range(w-b):
s += scm.comb(h+w-a-2-i, w-1-i, 1) * scm.comb(a-1+i, a-1, 1)
print(s%p) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s905471452 | p04046 | Time Limit Exceeded | MOD = 10**9+7
def add(a,b):
return (a+b) % MOD
def sub(a,b):
return (a-b) % MOD
def mul(a,b):
return ((a%MOD) * (b%MOD)) % MOD
def pow(a,n):
ans = 1
mag = a
for b in reversed(str(bin(n))):
if b == 'b': break
if b == '1':
ans = mul(ans, mag)
mag = mul(mag, mag)
return ans
def inv(a):... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s228904891 | p04046 | Time Limit Exceeded | MOD = 10**9+7
def add(a,b):
return (a+b) % MOD
def sub(a,b):
return (a-b) % MOD
def mul(a,b):
return ((a%MOD) * (b%MOD)) % MOD
def pow(a,n):
ans = 1
mag = a
for b in reversed(str(bin(n))):
if b == 'b': break
if b == '1':
ans = mul(ans, mag)
mag = mul(mag, mag)
return ans
def inv(a):... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s580804528 | p04046 | Time Limit Exceeded | import math
H,W,A,B=map(int, input().split())
def comb(x,y):
return(math.factorial(x)//(math.factorial(x-y)*math.factorial(y)))
alls=comb(H+W-2,W-1)
for i in range(B):
alls-=comb(H-A-1+i,H-A-1)*comb(W+A-2-i,A-1)
print(alls%(10**9+7)) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s834658060 | p04046 | Time Limit Exceeded | H, W, A, B = [int(x) for x in input().split()]
matrix = [[0 for x in range(W)] for y in range(H)]
matrix[0][0] = 1
for y in range(0, H):
for x in range(0, W):
# if not (y >= H-A and x < B):
if y < H-A or x >= B:
if y != 0:
matrix[y][x] += matrix[y-1][x]
if x !... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s230205803 | p04046 | Time Limit Exceeded | import math
class Paths:
def returnPaths(self,h,w,a,b):
ans=0
dic={}
for i in range(h+w): dic[i]=math.factorial(i)
for i in range(b,w):
checkpoint=dic[h-a-1+i]/(dic[h-a-1]*dic[i])
ans+=checkpoint*(dic[a-2+w-i]/(dic[a-1]*dic[w-1-i]))
ans%=10**9+7
print ans
if __name__ == "__main__":
h,w,a,b=[int(i... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s245179070 | p04046 | Time Limit Exceeded | def POW(a,b,MOD):
p = 1
while b > 0:
if b&1:
p = p*a%MOD
b >>= 1
a = (a*a)%MOD
return p
MOD = int(1e9+7)
H,W,A,B = map(int,input().split())
fact = [1] * (H+W+1)
inv = [1] * (H+W+1)
for i in range(H+W):
fact[i+1] = (i+1)*fact[i]%MOD
inv[i+1] = POW(fact[i+1],MOD-... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s286630773 | p04046 | Time Limit Exceeded | import re
class IO_for_Contest(object):
@staticmethod
def my_input():
# return raw_input()
return input()
@staticmethod
def read_from_input():
pass
@staticmethod
def read_line():
return IO_for_Contest.my_input().strip()
@staticmethod
def read_int():
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s611359489 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
#masu = [[0 for x in range(10)] for y in range(10)]
masu = [[0 for j in range(W)] for i in range(H)]
for j in range(W):
masu[0][j] = 1
for i in range(H-A):
masu[i][0] = 1
for i in range(1, H-A):
for j in range(1, W):
masu[i][j] = (masu[i-1][j] + masu[i][j-1]) % 1000000007
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s481814819 | p04046 | Time Limit Exceeded | M=10**9+7;F=[pow(X,M-2,M)for X in range(8**6)];H,W,A,B=map(int,input().split());Z=C=1
for I in range(H-1):Z=C=C*(W+H-B-2-I)*F[I+1]%M
for I in range(1,H-A):C=C*(B-1+I)*F[I]*(H-I)*F[W+H-B-1-I]%M;Z=(Z+C)%M
print(Z) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s367472849 | p04046 | Time Limit Exceeded | import functools;M=10**9+7;F=functools.lru_cache(2**16)(lambda X:pow(X,M-2,M));H,W,A,B=map(int,input().split());Z=C=1
for I in range(H-1):Z=C=C*(W+H-B-2-I)*F(I+1)%M
for I in range(1,H-A):C=C*(B-1+I)*F(I)*(H-I)*F(W+H-B-1-I)%M;Z=(Z+C)%M
print(Z) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s047534201 | p04046 | Time Limit Exceeded | F=lambda X:pow(X,M-2,M);M=10**9+7;H,W,A,B=map(int,input().split());Z=C=1
for I in range(min(W-1-B,H-1)):Z=C=C*(W+H-B-2-I)*F(I+1)%M
for I in range(1,H-A):C=C*(B-1+I)*F(I)%M*(H-I)*F(W+H-B-1-I)%M;Z=(Z+C)%M
print(Z) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s633315228 | p04046 | Time Limit Exceeded | F=lambda X:pow(X,M-2,M);M=10**9+7;H,W,A,B=map(int,input().split());Z=C=1
for I in range(min(W-1-B,H-1)):Z=C=C*(W+H-B-2-I)*F(I+1)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*F(I)*F(W+H-B-1-I)%M;Z=(Z+C)%M
print(Z) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s184908856 | p04046 | Time Limit Exceeded | F=lambda X:pow(X,M-2,M);M=10**9+7;H,W,A,B=map(int,input().split());Z=C=1
for I in range(W-1-B):Z=C=C*(W+H-B-2-I)*F(I+1)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*F(I)*F(W+H-B-1-I)%M;Z=(Z+C)%M
print(Z) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s514160218 | p04046 | Time Limit Exceeded | def G(N,R):
X=1
for I in range(min(R,N-R)):X=X*(N-I)*F(I+1)%M
return X
F=lambda X:pow(X,M-2,M);M=10**9+7;H,W,A,B=map(int,input().split());Z=G(H+W-2,H-1)
for I in range(B):C=(C*(H-A+I-1)*F(I)*(W-I)*F(A+W-I-1)if I else G(H-A+I-1,H-A-1)*G(A+W-I-2,A-1))%M;Z=(Z-C)%M
print(Z%M) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s157085939 | p04046 | Time Limit Exceeded | def G(N,R):
X=1
for I in range(R):X=X*(N-I)*F(I+1)%M
return X
F=lambda X:pow(X,M-2,M);M=10**9+7;H,W,A,B=map(int,input().split());Z=G(H+W-2,H-1)
for I in range(B):C=(C*(H-A+I-1)*F(I)*(W-I)*F(A+W-I-1)if I else G(H-A+I-1,H-A-1)*G(A+W-I-2,A-1))%M;Z-=C
print(Z%M) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s760048716 | p04046 | Time Limit Exceeded | C = int(1e9) + 7
h, w, a, b = [int(x) for x in input().split()]
# 1000000005 = 2^29 + 2^28 + 2^27 + 2^25 + 2^24 + 2^23 + 2^20 + 2^19 + 2^17 + 2^15 + 2^14 + 2^11 + 2^9 + 2^2 + 1
def pow(n):
ans = n
for i in range(1, 30):
n = (n * n) % C
if i in {29, 28, 27, 25, 24, 23, 20, 19, 17, 15, 14, 11, 9... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s213415181 | p04046 | Time Limit Exceeded | H,W,A,B = [int(n) for n in input().split(" ")]
answers = []
for total in range(B,W):
disp = 1
for n in range(1,total+(H-A)):
disp *= n
for m in range(1,H-A ):
disp //= m
for t in range(1,total + 1):
disp //= t
answers.append(disp)
for cnt,total in enumerate(range(B,W)):
d... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s208151375 | p04046 | Time Limit Exceeded | def read():
return map(int, input().split())
h, w, a, b = read()
m = 10 ** 9 + 7
line1 = [1 for _ in range(w)]
line2 = [0 for _ in range(w)]
for _ in range(1, h - a):
line2[0] = 1
for j in range(1, w):
line2[j] = (line2[j - 1] + line1[j]) % m
line1 = line2
line2 = [0 for _ in range(w)]
l... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s636275448 | p04046 | Memory Limit Exceeded | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s100684067 | p04046 | Accepted | MODD = 10**9 + 7
def modinv(a,m)-> int:
b = m
u = 1
v = 0
while (b):
t = a // b
a -= t * b
a,b= b,a
u -= t * v
u,v= v,u
u %= m
if (u < 0):
u += m
return u
fac=[1]*200001
infac=[1]*200001
aaa=1
for i in range(1,200001):
aaa=(aaa*i)%MODD
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s189716163 | p04046 | Accepted | h,w,a,b=map(int,input().split())
#コンビネーション逆元
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s765532624 | p04046 | Accepted | # coding:UTF-8
import sys
from math import factorial
MOD = 10 ** 9 + 7
def combInit(n):
fact = [1]
finv = [1]
for i in range(1, n + 1):
fact.append(fact[i - 1] * i % MOD)
finv.append(pow(fact[i], MOD - 2, MOD))
return [fact, finv]
def comb(n, k, f):
if n < k:
return 0
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s010651559 | p04046 | Accepted | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
#############
# Const... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s965975403 | p04046 | Accepted | P = 10**9+7
fac = [1]
ifac = [1]
ff = 1
for i in range(1,200001):
ff *= i
ff %= P
fac.append(ff)
ifac.append(pow(ff, P-2, P))
def ncr(n, r):
return (fac[n] * ifac[r] % P * ifac[n-r] % P);
h,w,a,b = map(int,input().split())
s = 0
nC = b-1
kC = 0
nD = w-b-1+h-1
kD = h-1
for i in range(h-a):
C = ncr(nC, kC)
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s169528854 | p04046 | Accepted | from math import comb
h,w,a,b = map(int,input().split())
s = 0
nC = b-1
kC = 0
nD = w-b-1+h-1
kD = h-1
p = 1000000007
fac = [1]
ff = 1
for i in range(1,200001):
ff *= i
ff %= p
fac.append(ff)
def ncr(n, r, p):
return (fac[n] * pow(fac[r], p-2, p) % p * pow(fac[n-r], p-2, p) % p);
for i in range(h-a):
C = nc... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s625645633 | p04046 | Accepted | import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7
class Combination:
"""
O(n)の前計算を1回行うことで,O(1)でnCr mod mを求められる
n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
使用例:
comb = Combination(1000000)
print(comb(5, 3)) # 10
"""
def __init__(self, n_max, mod=10**... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s837263719 | p04046 | Accepted | from sys import stdin
input = stdin.readline
MAX = 510000
MOD = 10**9 + 7
def MakeTable():
fac[0], fac[1] = 1, 1
finv[0], finv[1] = 1, 1
inv[1] = 1
for i in range(2, MAX):
fac[i] = fac[i - 1] * i % MOD
inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
finv[i] = finv[i - 1] * inv[i] ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s232388862 | p04046 | Accepted | #縦H A
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = (10**5)*2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.appen... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s231453289 | p04046 | Accepted | def permutation(n, k, mod):
s = 1
for _ in range(k):
s *= n
s %= mod
n -= 1
return s
def factorial(n, mod):
s = 1
for i in range(1, n + 1):
s *= i
s %= mod
return s
h, w, a, b = map(int, input().split())
mod = pow(10, 9) + 7
x = h - a + b - 1
y = w - b +... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s811976266 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)
for i in range(H + W):
factorials[i+1] = factorials[i] * (i + 1) % MOD
for i in range(H + W):
inv_factorials[i+1] = inv_factorials[i] * pow(i + 1, MOD - 2, MOD) % MOD
def modcomb(m... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s539781020 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)
tmp = 1
for i in range(H + W):
tmp = tmp * (i + 1) % MOD
factorials[i+1] = tmp
inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials))
def modcomb(m, n, mod):
retu... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s527216173 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)
for i in range(H + W):
factorials[i+1] = factorials[i] * (i + 1) % MOD
inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials))
def modcomb(m, n, mod):
return factorial... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s240389758 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)
for i in range(H + W):
factorials[i+1] = factorials[i] * (i + 1) % MOD
inv_factorials = list(map(lambda n: pow(n, -1, MOD), factorials))
def modcomb(m, n, mod):
return factorials[m] ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s313912718 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)
for i in range(H + W):
factorials[i+1] = factorials[i] * (i + 1) % MOD
inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials))
def modcomb(m, n, mod):
return factorial... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s742225886 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)
for i in range(H + W):
factorials[i+1] = factorials[i] * (i + 1) % MOD
inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials))
def modcomb(m, n, mod):
return factorial... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s152419936 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)
for i in range(H + W):
factorials[i+1] = factorials[i] * (i + 1) % MOD
inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials))
def modcomb(m, n, mod):
return factorial... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s463944960 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
def modperm(m, n, mod):
p = 1
for i in range(n):
p = p * (m - i) % mod
return p
def modcomb(m, n, mod):
if n > m - n:
n = m - n
p = modperm(m, n, mod)
q = pow(modperm(n, n, mod), mod - 2, mod)
return p * q % mod
t... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s979987850 | p04046 | Accepted | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
def modcomb(m, n, mod):
if n > m - n:
n = m - n
p = 1
q = 1
for i in range(n):
p = p * (m - i) % mod
q = q * (i + 1) % mod
result = p * pow(q, mod - 2, mod) % mod
return result
total = modcomb(H + W - 2, W - 1,... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s307340028 | p04046 | Accepted | M=10**9+7
H,W,A,B = map(int,input().split())
C = 1
ans = 1
for I in range(H-1):
ans = C = C*(W+H-B-2-I)*pow(I+1,M-2,M)%M
for I in range(1,H-A):
C = C*(B-1+I)*(H-I)*pow(I*(W+H-B-1-I),M-2,M)%M
ans+=C
print(ans%M) | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s906003068 | p04046 | Accepted | class Factorials:
# nに十分大きい数を入力
def __init__(self, n, mod):
self.mod = mod
# self.fac[i] ≡ i! (factorial:階乗)
self.fac = [1]
num = 1
for i in range(1, n+1):
num *= i
num %= mod
self.fac.append(num)
# self.rec[i] ≡ 1 / i! (recip... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s450458002 | p04046 | Accepted | class mod_comb_k():
def __init__(self, MAX_N = 10**6, mod = 10**9+7):
self.fact = [1]
self.fact_inv = [0] * (MAX_N + 4)
self.mod = mod
if MAX_N > mod:print('MAX_N > mod !')
for i in range(MAX_N + 3):
self.fact.append(self.fact[-1] * (i + 1) % self.mod)
self.fact_inv[-1] = pow(self.fact[-... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s619637048 | p04046 | Accepted | h, w, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
N = h + w + 10
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
fact[i] = fact[i - 1] * i % MOD
invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)
for i in range(N - 2, -1, -1):
invfact[i] = invfact[i + 1] * (... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s805700011 | p04046 | Accepted | h, w, a, b = map(int, input().split())
n = 2 * 10 ** 5
k = 2 * 10 ** 5
mod = 10**9 + 7
modinv_table = [-1] * (k+1)
modinv_table[1] = 1
for i in range(2, k+1):
modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod
def prepare_binomial_coefficients(n, k):
for i in range(1,n+1):
bc_num[i] = i * ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s444470453 | p04046 | Accepted | h, w, a, b = map(int, input().split())
n = 2 * 10 ** 5
k = 2 * 10 ** 5
mod = 10**9 + 7
modinv_table = [-1] * (k+1)
modinv_table[1] = 1
for i in range(2, k+1):
modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod
def prepare_binomial_coefficients(n, k):
for i in range(1,n+1):
bc_num[i] = i * ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s179125845 | p04046 | Accepted | mod = 10 ** 9 + 7
h, w, a, b = map(int, input().split())
def comb(n, r):
if n < r:return 0
if n < 0 or r < 0:return 0
return fa[n] * fi[r] % mod * fi[n - r] % mod
fa = [1] * (h + w + 1)
fi = [1] * (h + w + 1)
for i in range(1, h + w + 1):
fa[i] = fa[i - 1] * i % mod
fi[i] = pow(fa[i], mod - 2, mod)
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s548124321 | p04046 | Accepted | import sys
from functools import lru_cache
sys.setrecursionlimit(10**9)
def mul(x, y, mod):
x %= mod
y %= mod
return x * y % mod
def div(x, y, mod):
x %= mod
y %= mod
return x * mod_pow(y, mod - 2, mod) % mod
@lru_cache(maxsize=None)
def mod_pow(a, p, mod):
if p == 0:
return 1
if p % 2 == 0:
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s829535738 | p04046 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
class CmbMod:
def __init__(self, n, p):
"""
二項係数nCr(n個の区別できるものからr個のものを選ぶ組み合わせの数)をpで割った余りを求める
"""
self.n = n
self.p = p
self.fact = [1, 1]
self.factinv... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s470247790 | p04046 | Accepted | LIMIT = 2 * 10 ** 5
fac = [0] * (LIMIT + 10)
fac[0] = 1
inv = [0] * (LIMIT + 10)
MOD = 1_000_000_007
n = 1
for i in range(1, LIMIT + 1):
n *= i
n %= MOD
fac[i] = n
inv[LIMIT] = pow(fac[LIMIT], MOD - 2, MOD)
for i in range(LIMIT, -1, -1):
inv[i - 1] = (inv[i] * i) % MOD
def C(n, r):
return (fac[n] * ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s609453539 | p04046 | Accepted | H, W, A, B = map(int, input().split())
# H行W列 左下から縦A横B
def mod(num):
return num % (10 ** 9 + 7)
n = H + W + 1
fac = [0] * n
rev = [0] * n
fac[0] = 1
for i in range(1, n):
fac[i] = mod(fac[i-1] * i)
# 逆元の計算 x**(-1) ≡ x**(10**9 + 5) (mod 10**9 + 7)
rev[n-1] = pow(fac[n-1], 10**9 + 5, 10**9 + 7)
for i... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s371618820 | p04046 | Accepted | import sys
import numpy as np
from heapq import heappush, heappop
from bisect import bisect_left as bi_l, bisect_right as bi_r
from collections import deque, Counter, defaultdict
from itertools import combinations, product
import string
inf = float('inf')
MOD = 10**9+7
# MOD = 998244353
class NumberTheory():
def ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s354779992 | p04046 | Accepted | import sys
import numpy as np
from heapq import heappush, heappop
from bisect import bisect_left as bi_l, bisect_right as bi_r
from collections import deque, Counter, defaultdict
from itertools import combinations, product
import string
inf = float('inf')
MOD = 10**9+7
# MOD = 998244353
class NumberTheory():
def ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s849093151 | p04046 | Accepted | import sys
import numpy as np
from heapq import heappush, heappop
from bisect import bisect_left as bi_l, bisect_right as bi_r
from collections import deque, Counter, defaultdict
from itertools import combinations, product
import string
inf = float('inf')
MOD = 10**9+7
# MOD = 998244353
class NumberTheory():
def ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s148732450 | p04046 | Accepted | h,w,a,b=map(int,input().split())
fac=[0]*200001#iの階乗mod(1000000007)
inv=[0]*200001#iの逆元mod(1000000007)
fac[0]=1
ans=0
for i in range(1,200001):
fac[i]=fac[i-1]*i%1000000007
inv[200000]=pow(fac[200000],1000000005,1000000007)
for i in range(199999,0,-1):
inv[i]=(inv[i+1]*(i+1))%1000000007
inv[0]=1
for i in ra... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s455176771 | p04046 | Accepted | import sys
from functools import lru_cache
sys.setrecursionlimit(10**9)
def mul(x, y, mod):
x %= mod
y %= mod
return x * y % mod
def div(x, y, mod):
x %= mod
y %= mod
return x * mod_pow(y, mod - 2, mod) % mod
@lru_cache(maxsize=None)
def mod_pow(a, p, mod):
if p == 0:
return 1
if p % 2 == 0:
... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s177944718 | p04046 | Accepted | import sys
H,W,A,B = map(int,sys.stdin.readline().rstrip().split())
mod = 10**9+7
kaijou = [1]
for i in range(1,H+W-1):
kaijou.append((kaijou[-1]*i) % mod)
a = 0
for i in range(B):
b = kaijou[(H-A-1)+i]*pow(kaijou[i],mod-2,mod)*pow(kaijou[H-A-1],mod-2,mod)
b %= mod
b *= kaijou[(W+A-2)-i]*pow(kaijou[A-... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s295710462 | p04046 | Accepted | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def mul(x, y, mod):
x %= mod
y %= mod
return x * y % mod
def div(x, y, mod):
x %= mod
y %= mod
return x * mod_pow(y, mod - 2, mod) % mod
def mod_pow(a, p, mod):... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s563161959 | p04046 | Accepted | h,w,a,b=map(int,input().split())
p=10**9+7
#p=127
def modp_factorial(n):
s=1
for x in range(1,h+1):
s=(s*x) % p
return s
def modp_prod(lst):
s=1
for x in lst:
s=(s*x)%p
return s
def inv(n):
s=1
q=p-2
while q>0:
if q&1:
s=(s*n) % p
n=(n*n)... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s083985714 | p04046 | Accepted | h,w,a,b = map(int,input().split())
mod = 10**9+7
MAX = 2*10**5
fact = [1]*(MAX+1)
for i in range(1, MAX+1):
fact[i] = (fact[i-1]*i) % mod
inv = [1]*(MAX+1)
for i in range(2, MAX+1):
inv[i] = inv[mod % i]*(mod-mod//i) % mod
fact_inv = [1]*(MAX+1)
for i in range(1, MAX+1):
fact_inv[i] = fact_inv[i-1] * inv... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s126996691 | p04046 | Accepted | def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 3 * 10 ** 5 # N は必要分だけ用意する
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1] # factinv 計算用
for i in range(2,... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s806747189 | p04046 | Accepted | import math
h, w, a, b = [int(i) for i in input().split()]
MOD = 10**9 + 7
N = h + w
fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
rfact[i-1] = r = r * i % MOD
def comb(n, k):
return fact[n] * rfact[k... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s062565704 | p04046 | Accepted | h, w, a, b = map(int, input().split())
modulo = 10 ** 9 + 7
factorials = [1]
for i in range(1, h + w + 1):
factorials.append((factorials[-1] * i) % modulo)
inverses = []
for f in factorials:
inverses.append(pow(f, modulo - 2, modulo))
def cnk(n, k):
return (factorials[n] * inverses[k] * inverses[n - k]... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s260437334 | p04046 | Accepted | import sys
input = sys.stdin.readline
H,W,A,B= map(int,input().split())
MOD = 10**9 + 7
num = 200010
fact = [1] * (num+1)
ifact = [1] * (num+1)
for i in range(1,num+1):
fact[i] = (fact[i-1] * i) % MOD
ifact[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(1,num+1)[::-1]:
ifact[i-1] = (ifact[i] * i)% MOD
def nCr(... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s967868214 | p04046 | Accepted | H, W, A, B = map(int, input().split())
C = H - A
D = W - B
p = 1000000007
def power(a, b): #a^b (mod p)を求める #二分累乗法を使う
if b == 0:
return 1
elif b % 2 == 0:
return power(a, b//2) ** 2 % p
else:
return power(a, b//2) ** 2 * a % p
f = [1] #f[i] = i! % p
for i in range(H+W):
f.appen... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s827275144 | p04046 | Accepted | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def comb_mod(n, r):
res = 1
r = min(n - r, r)
for i in range(r):
res *= (n - i)
res %= MOD
res *= pow((r - i), MOD - 2, MOD)
return res
def main():
h, w, a, b =... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s169659581 | p04046 | Accepted |
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
factorial = [1]
modulo = 10**9+7
inverse_factorial = [0]
def pow1(a, p):
if p == 0:
return 1
half = pow1(a, p//2)
total = (half*half)%modulo
if p%2 == 0:
return ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s436950929 | p04046 | Accepted | H, W, A, B = map(int,input().split())
mod = 10**9+7
C = [1,1]
inv = [0,1]
Cinv = [1,1]
for i in range(2,H+W+1):
C.append((C[-1]*i)%mod)
inv.append((-inv[mod%i]*(mod//i)%mod))
Cinv.append(Cinv[-1]*inv[-1]%mod)
ans = 0
for i in range(H-A):
a = (C[i+B-1]*C[H-1-i+W-B-1])%mod
a = (a*Cinv[B-1])%mod
a ... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
s505323631 | p04046 | Accepted | import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.... | 2 3 1 1
| 2
| <span class="lang-en">
<p>Score : <var>400</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.