submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s906640821 | p04046 | Time Limit Exceeded | H,W,A,B = map(int, input().split())
judge = (A+B)/(H+W)
a = H-A
res = 0
import math
def comba(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if judge < 0.5:
base = comba(H+W-2, W-1)
for i in range(1,B+1):
ex1 = comba(a-1+i-1,i-1)
ex2 = comba(A-1+W-i,W-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... |
s118605670 | p04046 | Time Limit Exceeded | H,W,A,B = map(int, input().split())
a = H-A
res = 0
import math
def comba(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
base = comba((H+W-2), W-1)
for i in range(1,B+1):
ex1 = comba(a-1+i-1,i-1)
ex2 = comba(A-1+W-i,W-i)
exres = ex1 *ex2
res = res + exres
result =... | 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... |
s597929923 | p04046 | Time Limit Exceeded | import math
h, w, a, b = map(int, input().split())
all_comb = math.factorial(h+w-2)//(math.factorial(h-1)*math.factorial(w-1))
for i in range(a):
all_comb=all_comb-((math.factorial(h+b-i-2)//(math.factorial(h-i-1)*math.factorial(b-1))) * (math.factorial(w-b-1+i))//(mat... | 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... |
s945000342 | p04046 | Time Limit Exceeded | import math
h, w, a, b = map(int, input().split())
all_comb = math.factorial(h+w-2)//(math.factorial(h-1)*math.factorial(w-1))
array = [0 for i in range(a)]
for i in range(a):
array[i] = math.factorial(h+b-i-2)//(math.factorial(h-i-1)*math.factorial(b-1))
array[i] = arr... | 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... |
s816442589 | p04046 | Time Limit Exceeded | import math
h, w, a, b = map(int, input().split())
all_comb = math.factorial(h+w-2)//(math.factorial(h-1)*math.factorial(w-1))
array = [0 for i in range(a)]
for i in range(a):
array[i] = math.factorial(h+b-i-2)//(math.factorial(h-i-1)*math.factorial(b-1))
array[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... |
s677047765 | p04046 | Time Limit Exceeded | H, W, A, B = [int(i) for i in input().split(" ")]
from collections import deque
per = 10**9 + 7
goal_cnt = 0
que = deque([])
que.append((0, 0))
while que:
p = que.popleft()
if p[0] == H-1 and p[1] == W-1:
goal_cnt += 1
goal_cnt %= per
else:
for vh, vw in [[1, 0], [0, 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... |
s375123424 | p04046 | Time Limit Exceeded | H, W, A, B = [int(i) for i in input().split(" ")]
from collections import deque
field = [[0 if w <= B-1 and h >= H - A else 1 for w in range(W)] for h in range(H)]
goal_cnt = 0
que = deque([])
que.append((0, 0))
while que:
p = que.popleft()
if p[0] == H-1 and p[1] == W-1:
goal_cnt += 1
goal_... | 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... |
s805187488 | p04046 | Time Limit Exceeded | import collections, math, bisect
local = False
if local:
file = open("input.txt", "r")
import time
def inp():
if local:
return file.readline().rstrip()
else:
return input().rstrip()
def ints():
return [int(_) for _ in inp().split()]
if local:
start=time.time()
#H==rows
#W==... | 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... |
s735998444 | p04046 | Time Limit Exceeded | import math
import time
DIV_VALUE = 10**9 + 7
def calcModOfPow(a, n, p):
btm = a
ans = 1
while n != 0:
# print('btm: {}'.format(btm))
if n & 1:
ans = (ans * btm) % p
# print('ans: {}'.format(ans))
n = n>>1
btm = (btm**2) % p
# print(n)
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... |
s175265904 | p04046 | Time Limit Exceeded | H, W, A, B = list(map(int, input().split(' ')))
def move(i, j, H, W, A, B):
grid = [[0 for i in range(W)] for j in range(H)]
for i in range(H-A):
grid[i][0] = 1
for i in range(W):
grid[0][i] = 1
# print(grid)
for i in range(1, H):
for j in range(1, W):
# prin... | 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... |
s450519386 | p04046 | Time 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... |
s184433336 | p04046 | Time Limit Exceeded | MOD = 10**9+7
def modpow(base, pow, mod):
res = 1
while pow > 0:
if pow & 1:
res = res * base % mod
base = base**2 % mod
pow >>= 1
return res
def modmul(a, b, mod):
return a*b % mod
def solve(h,w,a,b):
fact = [1]
fact_inv = [1]
for i in range(1, h+w):
fact.append(fact[-1]*i % 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... |
s208525247 | p04046 | Time Limit Exceeded | H,W,A,B=map(int, input().split())
b=[[0 for j in range(W)] for i in range(H)]
MOD=1000000007
b[0][0]=1
for j in range(H):
for i in range(W):
if j+1<H and (j+1<H-A or i>=B):
b[j+1][i]+=b[j][i]
b[j+1][i]%=MOD
if i+1<W and (j<H-A or i+1>=B):
b[j][i+1]+=b[j][i]
b[j][i+1]%=MOD
print(b[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... |
s016047136 | p04046 | Time Limit Exceeded | h,w,a,b = map(int,input().split())
mod = 10**9 + 7
dp = [[0 for i in range(h+1)] for j in range(w+1)]
for i in range(w):
for j in range(h):
dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%mod
if i == 0 and j == 0:
dp[i+1][j+1] = 1
if i < b and j >= h-a:
dp[i+1][j+1] = 0
pr... | 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... |
s695346447 | p04046 | Time Limit Exceeded | h,w,a,b = map(int,input().split())
mod = 10**9 + 7
dp = [[0 for i in range(h+1)] for j in range(w+1)]
for i in range(w):
for j in range(h):
dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%mod
if i == 0 and j == 0:
dp[i+1][j+1] = 1
if i < b and j >= h-a:
dp[i+1][j+1] = 0
pri... | 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... |
s666069316 | p04046 | Time Limit Exceeded | from operator import mul
from functools import reduce
def combinations_count(n, r):
r = min(r, n - r)
numer = reduce(mul, range(n, n - r, -1), 1)
denom = reduce(mul, range(1, r + 1), 1)
return numer // denom
"""
kari1 = '100000 100000 99990 99990'
in1 = kari1.split()
"""
in1 = input().split()
H = in... | 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... |
s043270376 | p04046 | Time Limit Exceeded | h,w,a,b = map(int, input().split())
def modinv(a, mod=10**9+7):
return pow(a, mod-2, mod)
def comb(n, r, mod=10**9+7):
r = min(r, n-r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i+1, mod) % mod
return res
ans=0
for i in range(h-a):
pre=comb(i+b-1,i)
post=comb(h+w-b-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... |
s696497407 | p04046 | Time Limit Exceeded | def f(x):
if x==0:
return 1
else:
fac=1
for i in range(1,x+1):
fac*=i
return fac
def c(x,y):
return f(x+y)//(f(x)*f(y))
h,w,a,b=map(int,input().split())
ans=0
ans+=c((h-a-1),(b))*c((a),(w-b-1))
for i in range(h-a-1):
ans+=c(i,b)*c(h-i-1,w-b-2)
print(ans%(10**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... |
s284607235 | p04046 | Time Limit Exceeded | class ModInt:
def __init__(self, num, mod):
self.num = num
self.mod = mod
def __str__(self):
return str(self.num)
def __repr__(self):
return "ModInt(num: {}, mod: {}".format(self.num, self.mod)
def __add__(self, other):
ret = self.num + other.num
ret %=... | 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... |
s434821779 | p04046 | Time Limit Exceeded | from scipy.misc import comb
H,W,A,B=map(int,input().split())
p=0
for i in range(B+1,W+1):
p+=comb(H-A+i-2,i-1,exact=True)*comb(W-i+A-1,A-1,exact=True)
k=p%1000000007
print(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... |
s203886785 | p04046 | Time Limit Exceeded | # D - いろはちゃんとマス目
def combmod(n,k,mod):
a = 1
b = 1
for i in range(k):
a = a * (n-i) % mod
b = b * (i+1) % mod
return a * pow(b, mod-2, mod) % mod
h,w,a,b=map(int,input().split())
mod=10**9+7
ans=0
for i in range(b,w):
ans+=combmod(i+h-1-a,i,mod)*combmod(w-1-i+a-1,a-1,mod)
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... |
s539211967 | p04046 | Time Limit Exceeded | import fractions
H,W,A,B=map(int,input().split())
def C(n,m):
if n*m==0:
C =1
else:
bunbo=[0]*min(m,n)
bunsi=[0]*min(m,n)
for k in range(min(m,n)):
bunbo[k]=min(m,n)-k
bunsi[k]=n+m-k
for k in range(min(m,n)):
for j in range(min(n,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... |
s257821303 | p04046 | Time Limit Exceeded | H,W,A,B=map(int,input().split())
def bikkuri(n,m):
x=n
if m>1:
for k in range(1,m):
x=x*(n-k)
return x
def C(n,m):
if m==0:
C=1
else:
C=bikkuri(n+m,m)//bikkuri(m,m)
return int(C)
Total = C(H-1,W-1)
dame = 0
for k in range(B):
dame += C(k,H-A-1)*C(W-1-k,A-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... |
s526925239 | p04046 | Time Limit Exceeded | import sys
sys.stdin.readline
MOD=10**9+7
class Fp(int):
def __new__(self,x=0):return super().__new__(self,x%MOD)
def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
def __add__(self,value):return self.__class__(super().__add__(value))
def __sub__(self,value):return self.__class__(super()._... | 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... |
s825176199 | p04046 | Time Limit Exceeded | H,W,A,B = map(int,input().split())
mod = 10**9+7
def comb(a,b,p):
if a<0 or b<0 or a<b: return 0
if a==0 or b==0: return 1
fa = 1
fb = 1
fab = 1
for i in range(1,a+1):
fa = (fa*i)%p
for i in range(1,b+1):
fb = (fb*i)%p
for i in range(1,a-b+1):
fab = (fab*i)%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... |
s715734034 | p04046 | Time Limit Exceeded | import sys
# 回答の最大値(固定数)
T = 10**9 + 7
# 入力
H, W, A, B = map(int, input().split())
# 計算済みの経路
route = {(0, 0):1}
# 計算対象の経路
stack = [(H-1, W-1)]
# 計算対処の経路が空になるまで繰り返し
while stack != []:
# 現在のマス
curr = stack.pop()
# 一つ手前のマス(上)。
if curr[0]-1 >= 0:
upper = (curr[0]-1, curr[1])
else:
... | 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... |
s818276734 | p04046 | Time Limit Exceeded | import math
MOD = 10**9+7
def xgcd(a, b):
x0, y0, x1, y1 = 1, 0, 0, 1
while b != 0:
q, a, b = a // b, b, a % b
x0, x1 = x1, x0 - q * x1
y0, y1 = y1, y0 - q * y1
return a, x0, y0
def modinv(a):
g, x, y = xgcd(a, MOD)
return x % MOD
fact = [1] * 200100
for i in range(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... |
s397565709 | p04046 | Time Limit Exceeded | import math
MOD = 10**9+7
def xgcd(a, b):
x0, y0, x1, y1 = 1, 0, 0, 1
while b != 0:
q, a, b = a // b, b, a % b
x0, x1 = x1, x0 - q * x1
y0, y1 = y1, y0 - q * y1
return a, x0, y0
def modinv(a):
g, x, y = xgcd(a, MOD)
return x % MOD
fact = [1] * 200100
for i in range(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... |
s812881685 | p04046 | Time Limit Exceeded | import math
MOD = 10**9+7
def modinv(x):
ret = 1
m = MOD - 2
for i in range(0, 32):
if m & (1 << i):
ret *= x
ret %= MOD
x *= x
x %= MOD
return ret
fact = [1] * 200100
for i in range(1, 200100):
fact[i] = fact[i-1] * i % MOD
def calc(h, w):
... | 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... |
s354250863 | p04046 | Time Limit Exceeded | import math
MOD = 10**9+7
def modinv(x):
ret = 1
m = MOD - 2
'''
while m:
if m & 1:
ret = ret * x % MOD
x = x * x % MOD
m >>= 1
'''
for i in range(0, 32):
if m & (1 << i):
ret *= x
ret %= MOD
x *= x
x %= 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... |
s020540591 | p04046 | Time Limit Exceeded | import math
h, w, a, b = map(int, input().split())
if h - a > w - b:
hh = h
h = w
w = hh
del hh
aa = a
a = b
b = aa
del aa
x = h - a + b - 1
y = w + a - b - 1
z = h - 1
d = math.factorial(y) // (math.factorial(y - z) * math.factorial(z))
c = d
for t in range(0, h - a - 1):
d = ((d * (x - 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... |
s586082088 | p04046 | Time Limit Exceeded | from operator import mul
from functools import reduce
def combination(n, r):
r = min(r, n - r)
return reduce(mul, range(n, n - r, -1), 1)//reduce(mul, range(1, r + 1), 1)
h, w, a, b = map(int, input().split())
c=0
for k in range(h - a ):
c += (combination(b + k - 1, k) * combination(h + w - b - k - 2, w... | 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... |
s419856347 | p04046 | Time Limit Exceeded | from operator import mul
from functools import reduce
def combination(n, r):
r = min(r, n - r)
return reduce(mul, range(n, n - r, -1), 1)//reduce(mul, range(1, r + 1), 1)
h, w, a, b = map(int, input().split())
c=0
for k in range(h - a ):
c += combination(b + k - 1, k) * combination(h + w - b - k - 2, w ... | 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... |
s452286580 | p04046 | Time Limit Exceeded | from array import *
h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = 2*10**5
def modpow(a, b):
res = 1
while b:
if (b & 1):
res = (res * a) % MOD
a = (a * a) % MOD
b >>= 1
return res
def nCr(n, r):
if r == 0 or n == r:
return 1
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... |
s303334323 | p04046 | Time Limit Exceeded | h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = 3*10**5
def modpow(a, b):
res = 1
while b:
if (b & 1):
res = (res * a) % MOD
a = (a * a) % MOD
b >>= 1
return res
def nCr(n, r):
if r == 0 or n == r:
return 1
return (((f[n] * ivf[n-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... |
s607107515 | p04046 | Time Limit Exceeded | h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = 2*10**5
def modpow(a, b):
res = 1
while b:
if (b & 1):
res = (res * a) % MOD
a = (a * a) % MOD
b >>= 1
return res
def nCr(n, r):
if r == 0 or n == r:
return 1
return (((f[n] * ivf[n-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... |
s903485079 | p04046 | Time Limit Exceeded | from math import factorial
h, w, a, b = map(int, input().split(' '))
# MAX = max(h, w)
MOD = 10**9 + 7
MAX = 10**6
def modpow(a, b):
res = 1
while b:
if (b & 1):
res = (res * a) % MOD
a = (a * a) % MOD
b >>= 1
return res
def nCr(n, r):
if r == 0 or n == 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... |
s143701124 | p04046 | Time Limit Exceeded | h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = 10**6 + 5
def mod(a, b):
r = 1
while b:
if b & 1:
r = (r * a) % MOD
a = (a * a) % MOD
b >>= 1
return r
f = [0]*MAX
invf = [0]*MAX
def ncr(n, r):
if r == 0 or r == n:
return 1
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... |
s266037170 | p04046 | Time Limit Exceeded | mod=10**9+7
H,W,A,B=map(int,input().split())
n=[[0 for j in range(W)] for i in range(H)]
n[0][0]=1
for j in range(1,W):
n[0][j]=n[0][j-1]
for i in range(1,H-A):
n[i][0]=n[i-1][0]
for j in range(1,W):
n[i][j]=(n[i-1][j]+n[i][j-1])%mod
for i in range(H-A,H):
n[i][B]=n[i-1][B]
for j in rang... | 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... |
s641833792 | p04046 | Time Limit Exceeded | h,w,a,b=map(int,input().split())
ans = 0
mod = 10**9 + 7
flist = [1] * (h+w+1)
for i in range(1,h+w):
flist[i] = (flist[i-1] * i)
def cmb(n,r):
return flist[n]//(flist[r]*flist[n-r])
for x in range(b,w):
c = x + (h - a - 1)
d = (w - x - 1) + (a - 1)
e = cmb(c, x) * cmb(d, a - 1)
ans = (ans+e)... | 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... |
s617073186 | p04046 | Time Limit Exceeded | from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
H,W,A,B = map(int, input().split())
mod = 1000000007
#全体
total = cmb(H+W-2,W-1)
#侵入不可
forbidden... | 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... |
s693150121 | p04046 | Time Limit Exceeded | from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
nums = input().split()
H = int(nums[0])
W = int(nums[1])
A = int(nums[2])
B = int(nums[3])
mod = 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... |
s260982711 | p04046 | Time Limit Exceeded | def comb(n,k,p):
from math import factorial
if n<0 or k<0 or n<k: return 0
if n==0 or k==0: return 1
a=factorial(n)%p
b=factorial(k)%p
c=factorial(n-k)%p
return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
if b==0: return 1
if b%2==0:
d=power_func(a,b//2,p)
return d*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... |
s139120793 | p04046 | Time Limit Exceeded | base = 10**9 + 7
def comb(x, y):#xCy = [x-1]C[y-1] * n / k
res = 1
for i in range(x):
res = res * (x-i)
for i in range(y):
res = res // (i+1)
for i in range(x-y):
res = res // (i+1)
return res % base
H, W, A, B = map(int, input().split())
res = 0
for i in range(W-B):
res += comb(H-A-1 + W-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... |
s153441250 | p04046 | Time Limit Exceeded | base = 10 ** 9 + 7
res = 0
H, W, A, B = map(int, input().split())
f1 = [1 for i in range(W)]
f2 = [0 for i in range(W)]
for i in range(H-1): #f1 -> #f2
for j in range(W):
if i > H-2-A and j<B:
f2[j] = 0
elif j == 0:
f2[0] = f1[0]
else:
f2[j] = f1[j] + f2[j-1]
for j in range(W):
f... | 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... |
s270908861 | p04046 | Time Limit Exceeded | def examD():
from operator import mul
from functools import reduce
def comb2(n, r):
r = min(n - r, r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
H, W, A, B =LI()
k = W-B
ans = 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... |
s280001495 | p04046 | Time Limit Exceeded | #D問題
import math
H,W,A,B = map(int,input().split())
mod = 10**9 + 7
M = H+W-1
fact = [1 for i in range(M)]
for i in range(M):
if i == 0:
pass
else:
fact[i] = (fact[i-1]*i)%mod
refact = [1 for i in range(M)]
m = mod-2
b = bin(m)
b = b.lstrip("0b")
b = b[::-1]
m2 = len(b)
for i in range(... | 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... |
s213961321 | p04046 | Time Limit Exceeded | p = 10**9+7
def power(a,x):
if x==0:
return 1
if x%2==0:
return (power((a**2)%p,x//2))%p
else:
return (a*power((a**2)%p,(x-1)//2))%p
H,W,A,B = map(int,input().split())
tot = 0
for k in range(W-B):
a1 = 1
for i in range(H-A-k,H-A+B):
a1 = (a1*i)%p
b1 = 1
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... |
s316109070 | p04046 | Time Limit Exceeded | p = 10**9+7
def power(a,x):
if x==0:
return 1
if x%2==0:
return (power(a**2,x//2))%p
else:
return (a*power(a**2,(x-1)//2))%p
H,W,A,B = map(int,input().split())
tot = 0
for k in range(W-B):
a1 = 1
for i in range(H-A-k,H-A+B):
a1 = (a1*i)%p
b1 = 1
for i in range... | 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... |
s862138933 | p04046 | Time Limit Exceeded |
import math
H, W, A, B = map(int,input().split())
e = 10**9 + 7
def power(a,b):
if b == 0:
return 1
elif b == 1:
return a % e
elif b%2 == 0:
return power(a,b//2)**2 % e
else:
return power(a,b//2)**2*a % e
M = [1]
for i in range(1,H+W):
a = M[i-1]*i%e
M.appe... | 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... |
s565298997 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int,input().split())
e = 10**9 + 7
def power(a,b):
if b == 0:
return 1
elif b == 1:
return a % e
elif b%2 == 0:
return power(a,b//2)**2 % e
else:
return power(a,b//2)**2*a % e
M = [1]
N = [1]
for i in range(1,H+W):
a = M[i-1]*i%e
... | 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... |
s712940128 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int,input().split())
e = 10**9 + 7
def power(a,b):
if b == 0:
return 1
elif b == 1:
return a % e
elif b%2 == 0:
return power(a,b//2)**2 % e
else:
return power(a,b//2)**2*a % e
M = [1]
for i in range(1,H+W):
a = M[i-1]*i%e
M.append... | 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... |
s170218371 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int,input().split())
def f(a,b):
p = math.factorial(a+b-2)
q = math.factorial(a-1)
r = math.factorial(b-1)
S = p // (q*r)
return S
T = 0
for i in range(1,B+1):
P = f(H-A,i)
Q = f(A,W-i+1)
T = T + P*Q
R = f(H,W) - T
ans = R % (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... |
s587924982 | p04046 | Time Limit Exceeded | import math
h, w, a, b = map(int, input().split())
def combination(num1, num2):
return math.factorial(num1 + num2) // (math.factorial(num1) * math.factorial(num2))
all = combination(h - 1, w - 1)
for i in range(b):
comb_i = combination(h - a - 1, i)
to = combination(a - 1, w - 1 - i)
all -= comb_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... |
s168903140 | p04046 | Time Limit Exceeded | MOD = 1000000007
def mod_pow(a, n, mod):
"""
二分累乗法による a^n (mod m)の実装
:param a: 累乗の底
:param n: 累乗の指数
:param mod: 法
:return: a^n (mod m)
"""
result = 1
a_n = a
while n > 0:
if n & 1:
result = result * a_n % mod
a_n = a_n * a_n % mod
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... |
s195929656 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
# modしながらコンビネーションを求める
def mod_cmb(n, r, mod):
p, q = 1, 1
for i in range(r):
p = p * (n - i) % mod
q = q * (i + 1) % mod
return p * mod_inverse(q, mod) % mod
def d_cmb(n, r, mod):
return mod_cmb(n + r - 1, r, mod)
# modした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... |
s887207033 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
# modしながらコンビネーションを求める
def mod_cmb(n, r, mod):
p, q = 1, 1
for i in range(r):
p = p * (n - i) % mod
q = q * (i + 1) % mod
return p * mod_inverse(q, mod) % mod
# modしたa^bを求める
def mod_pow(a, p, mod):
if p == 0:
return 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... |
s353544471 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
# modしながらコンビネーションを求める
def mod_cmb(n, r, mod):
p, q = 1, 1
for i in range(r):
p = p * (n - i) % mod
q = q * (i + 1) % mod
return p * mod_inverse(q, mod) % mod
# modしたa^bを求める
def mod_pow(a, p, mod):
if p == 0:
return 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... |
s041156602 | p04046 | Time Limit Exceeded | from math import factorial
h,w,a,b= list(map(int, input().split()))
m=1000000007
ans=0
a1=(factorial(h-a+b-1))//(factorial(h-a-1)*factorial(b))
a2=(factorial(w-b+a-2))//(factorial(a-1)*factorial(w-b-1))
ans+=a1*a2
ans%=m
for i in range(1,w-b):
a1=a1*(h-a+b+i-1)//(b+i)
a2=a2*(w-b-i)//(w-b-i+a-1)
tmp=a1*a2%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... |
s292264151 | p04046 | Time Limit Exceeded | from math import factorial
h,w,a,b= list(map(int, input().split()))
m=1000000007
ans=0
# a1=(factorial(h-a+b+i-1))//(factorial(h-a-1)*factorial(b+i))
# a2=(factorial(w-b-i+a-2))//(factorial(a-1)*factorial(w-b-i-1))
for i in range(w-b):
if i==0:
a1=(factorial(h-a+b+i-1))//(factorial(h-a-1)*factorial(b+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... |
s804796588 | p04046 | Time Limit Exceeded | def cmb(n, r):
if n - r < r: r = n - r
if r == 0: return 1
if r == 1: return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2,r+1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for ... | 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... |
s768112451 | p04046 | Time Limit Exceeded | def cmb(n, r):
if n - r < r: r = n - r
if r == 0: return 1
if r == 1: return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2,r+1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for ... | 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... |
s737009513 | p04046 | Time Limit Exceeded | h,w,a,b = map(int,input().split())
res = []
for i in range(0,h):
res.append([0 for i in range(w)])
for i in range(0,w):
res[0][i] = 1
for j in range(1,h):
res[j][0] = 1
for i in range(h-a,h):
for j in range(0,b):
res[i][j] = -1
for i in range(1,h):
for j in range(1,w):
if res[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... |
s664350980 | p04046 | Time Limit Exceeded | h,w,a,b=map(int,input().split())
dp=[[1]*w]+[[1]+[0]*(w-1) for _ in range(h-1)]
for i in range(h-a,h):
dp[i]=[-1]*b+[0]*(w-b)
for i in range(1,h):
for j in range(1,w):
if dp[i][j]==-1:
continue
if dp[i][j-1]==-1:
dp[i][j]=dp[i-1][j]
continue
dp[i][j]=dp[i-1][j]+dp[i][j-1]
dp[i][j]%... | 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... |
s389037675 | p04046 | Time Limit Exceeded | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): ... | 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... |
s131115056 | p04046 | Time Limit Exceeded | from math import factorial
H, W, A, B = map(int, input().split())
ans = 0
root = factorial((H-A-1) + (W-1)) // (factorial(H-A-1) * factorial(W-1))
for i in range(W, B, -1):
ans += root
root *= (i-1) * ((A-1) + (W-i+1))
root //= ((H-A-1) + (i-1)) * (W-i+1)
print(ans % (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... |
s766207830 | p04046 | Time Limit Exceeded | import math
h, w, a, b = map(int, input().split(" "))
count = 0
for inter_h in range(h - a):
molec = math.factorial(b - 1 + inter_h)
denom = math.factorial(b - 1) * math.factorial(inter_h)
comb_1 = molec // denom
molec = math.factorial(w - b - 1 + h - inter_h - 1)
denom = 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... |
s789436005 | p04046 | Time Limit Exceeded | h, w, a, b = map(int, input().split())
MOD = 1000000007
dp = [[0 for _ in range(w)] for _ in range(h)]
block = [[True for _ in range(w)] for _ in range(h)]
for y in range(h-1, h-a-1, -1):
for x in range(b):
block[y][x] = False
dp[0][0] = 1
for i in range(1, h):
if block[i][0]:
dp[i][0] = dp[... | 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... |
s606514966 | p04046 | Time Limit Exceeded | import math
from collections import deque
H,W,A,B=map(int,input().split())
# H,W,A,B=10,7,3,4
# H,W,A,B=100000,100000,44444,55555
array=[[0 for i in range(W)] for j in range(H)]
#S->P->G の実装
#与えられたHとWで最大値を算出
# ue=math.factorial( H-1 + W-1 )
# sita=math.factorial( H-1 )*math.factorial( W-1 )
# result = ue//sita
# print... | 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... |
s385632737 | p04046 | Time Limit Exceeded | import math
from collections import deque
# H,W,A,B=map(int,input().split())
# H,W,A,B=10,7,3,4
H,W,A,B=100000,100000,44444,55555
# array=[[0 for i in range(W)] for j in range(H)]
#S->P->G の実装
#与えられたHとWで最大値を算出
# ue=math.factorial( H-1 + W-1 )
# sita=math.factorial( H-1 )*math.factorial( W-1 )
# result = ue//sita
# pri... | 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... |
s191026966 | p04046 | Time Limit Exceeded | h,w,a,b=[int(i) for i in input().split()]
p=10**9+7
kkk={}
def kai(n):
if n in kkk:
return kkk[n]
a=1
for i in range(1,n+1):
a*=i
a%=p
kkk[n]=a
return a
def conv(k,n):
a=kai(n)*pow(kai(k),p-2,p)*pow(kai(n-k),p-2,p)
return a%p
ans=0
for i in range(b+1,w+1):
ans+=conv(i-1,i+h-a-2)*conv(w-i,a+w... | 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... |
s721541235 | p04046 | Time Limit Exceeded | h,w,a,b=[int(i) for i in input().split()]
p=10**9+7
def kai(n):
a=1
for i in range(1,n+1):
a*=i
a%=p
return a
def conv(k,n):
a=kai(n)*pow(kai(k),p-2,p)*pow(kai(n-k),p-2,p)
return a%p
ans=0
for i in range(b+1,w+1):
ans+=conv(i-1,i+h-a-2)*conv(w-i,a+w-i-1)
ans%=p
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... |
s527805011 | p04046 | Time Limit Exceeded | import math
def nCr(n,r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
h,w,a,b=map(int,input().split())
amari = 10**9+7
#1.境界まで行く順路のパターン数を求める
l1 = [0 for i in range(w-b)]
for i in range(len(l1)):
l1[i]=nCr((h-a-1)+b+i,b+i)
#2.境界の1コ下からゴールまで行く順路のパターン数を求める
l2 = [0 for i in range(w-b)]
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... |
s764206687 | p04046 | Time Limit Exceeded | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
def pow_mod(x, p):
res = 1
while p:
if p % 2:
res = res * x % MOD
x = x * x % MOD
p //= 2
return res
F = [1]
invF = [1]
def comb_mod(n, r):
return F[n] * invF[r] * invF[n - r] % MOD
for i in range(1, 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... |
s328101396 | p04046 | Time Limit Exceeded | h,w,a,b=map(int,input().split())
grid=[[0]*(w+1) for _ in range(h+1)]
grid[1][1]=1
for x in range(1,w+1):
for y in range(1,h+1):
if x>b or y<h-a+1:
grid[y][x]=grid[y][x]+grid[y-1][x]+grid[y][x-1]
print(grid[y][x]%(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... |
s160533374 | p04046 | Time Limit Exceeded | H, W, A, B = [int(_) for _ in input().split()]
p = 10 ** 9 + 7
# 二分累乗法 で n^x % p を求める
# pow(n,x,p) で得られるので次からはそっちつかう
def power(n, x, p):
a = n # a^(2^0), a^(2^1), ...
ans = 1
while x > 0:
if x & 1:
ans = (ans * a) % p
x = x >> 1
a = (a ** 2) % p
return ans
def so... | 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... |
s862129935 | p04046 | Time Limit Exceeded | import math
H,W,A,B = map(int,input().split())
res1 = math.factorial(H+W-2)//(math.factorial(H-1)*math.factorial(W-1))
res1 = res1 % (10**9 + 7)
res2 = 0
for i in range(B):
temp1 = math.factorial(H-A-1+i)//(math.factorial(H-A-1)*math.factorial(i))
temp1 = temp1 % (10**9 + 7)
if A == 1:
temp2 = 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... |
s320093367 | p04046 | Time Limit Exceeded | # ABC042D - いろはちゃんとマス目 / Iroha and a Grid (ARC058D)
def main():
H, W, A, B = tuple(map(int, input().split()))
a = H - A + 1
MOD = 10 ** 9 + 7
prev, cur = [0] * (W + 1), [0] * (W + 1)
cur[0] = 1
for i in range(1, H + 1):
for j in range(1, W + 1):
if i >= a and j <= 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... |
s491291362 | p04046 | Time Limit Exceeded | high, width, y, x = map(int, input().split())
def nCr(n, r):
return ((((fact[n]*finv[n-r])%mod)*finv[r])%mod)
def powmod(a, n, m):
if n == 0:
return 1
elif n == 1:
return (a % m)
elif n%2 == 0:
s = powmod(a, int(n/2), m)
temp = (s * s) % m
return temp
else:
... | 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... |
s991198018 | p04046 | Time Limit Exceeded | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)
MOD = 1000000007 # type: int
def solve(H: int, W: int, A: int, B: int):
#H, W = W, H
#A, B = B, A
def comb(n, k):
k = min(k, n - k)
if n == 0:
return 0
if k == 0:
return 1
ret = 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... |
s247429689 | p04046 | Time Limit Exceeded | h,w,a,b=map(int,input().split())
def n_func(n,mod=10**9+7):
ans=1
for i in range(1,n+1):ans=(ans*i)%mod
return ans
def inv_n(n,mod=10**9+7):return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):return inv_n(n_func(n-r,mod),mod)*n_func(n,mod)%mod
def nCr(n,r,mod=10**9+7):return inv_n(n_func(n-r,mod)*n_func(r,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... |
s058034406 | p04046 | Time Limit Exceeded | h, w, a, b = map(int, input().split())
posA_w = b
posA_h = h - a
posB_w = w - b
posB_h = h
pa = [1] * h
pb = [1] * h
result = 0
for i in range(1, max(posA_w, posB_w)):
for j in range(1, h):
if i < posA_w:
pa[j] = pa[j - 1] + pa[j]
if i < posB_w:
pb[j] = pb[j - 1] + pb[j]
... | 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... |
s847667397 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
#O(N)
first = []
for i in range(0, H - A):
if i == 0:
tmp = 1
first.append(tmp)
continue
tmp = (tmp * (B + i - 1) // i)
first.append(tmp)
# print (first)
#O(N)
second = []
for i in range(0, H):
if i == 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... |
s553424266 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
first = []
for i in range(0, H - A):
if i == 0:
tmp = 1
first.append(tmp)
continue
tmp = (tmp * (B + i - 1) // i)
first.append(tmp)
# print (first)
second = []
for i in range(H - A):
if i == 0:
tmp = ... | 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... |
s007546088 | p04046 | Time Limit Exceeded | from math import *
p = 1000000007
def make_ft(max):
ft = [0] * (max+1)
x = 1
ft[0] = 1
# ft[i] == i!
for i in range(1, max+1):
x *= i
x %= p
ft[i] = x
return ft
# i!^-1 == i!^(p-2) (mod p)
def make_ift(max, ft):
ift = [0] * (max+1)
ift[0] = 1
for i in range... | 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... |
s205133289 | p04046 | Time Limit Exceeded | from math import *
p = 1000000007
ft = []
ift = []
def make_ft(max):
x = 1
ft.append(x)
# ft[i] == i!
for i in range(1, max+1):
x *= i
x %= p
ft.append(x)
return
# i!^-1 == i!^(p+2) (mod p)
def make_ift(max):
ift.append(1)
for i in range(1, max+1):
invf = 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... |
s306191422 | p04046 | Time Limit Exceeded | from functools import lru_cache
h, w, a, b = map(int, input().split())
@lru_cache(maxsize=200000)
def func(i, j) :
if j == 0 :
return 1
else :
return func(i, j-1)*(i+j)//j
ha_w = [func(h-a-1, i)%(10**9+7) for i in range(w)]
a_wb = [func(a-1, i)%(10**9+7) for i in range(w-b)]
ans = sum([ha_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... |
s939592192 | p04046 | Time Limit Exceeded | [h,w,a,b]=[int(_) for _ in input().split()]
import math
def p(x,y):
if x==0 or y==0: a=0
elif x==1 or y==1: a=1
else: a=math.factorial(x+y-2)//math.factorial(x-1)//math.factorial(y-1)
return a
n=0
for i in range(h-a):
n+=(p(i+1,b))%((10**9)+7)*(p(h-i,w-b))%((10**9)+7)
n%=(10**9)+7
print(int(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... |
s970174267 | p04046 | Time Limit Exceeded | [h,w,a,b]=[int(_) for _ in input().split()]
import math
def p(x,y):
if x==0 or y==0: a=0
elif x==1 or y==1: a=1
else: a=math.factorial(x+y-2)//math.factorial(x-1)//math.factorial(y-1)
return a
n=0
for i in range(h-a):
n+=(p(i+1,b)*p(h-i,w-b))%((10**9)+7)
n%=(10**9)+7
print(int(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... |
s188568731 | p04046 | Time Limit Exceeded | import sys
sys.setrecursionlimit(1000000)
h, w, a, b = map(int, input().split())
dx = [1, 0]
dy = [0, 1]
def dfs(nowx, nowy):
if nowx == w and nowy == h:
return 1
if nowx > w or nowy > h or (1 <= nowx <= b and (h - a + 1) <= nowy <= h):
return 0
count = 0
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... |
s739046917 | p04046 | Time Limit Exceeded | [h,w,a,b]=[int(_) for _ in input().split()]
import math
def p(x,y):
if x==0 or y==0: a=0
elif x==1 or y==1: a=1
else: a=math.factorial(x+y-2)//math.factorial(x-1)//math.factorial(y-1)
return a
n=0
for i in range(h-a):
n+=p(i+1,b)*p(h-i,w-b)
n%=(10**9)+7
print(int(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... |
s830228489 | p04046 | Time Limit Exceeded | mod = 10**9+7
def combi(m,n):
child = 1
mom = 1
while n != 0:
child *= m
child %= mod
mom *= n
mom %= mod
m -= 1
n -= 1
return (child*modpow(mom,mod-2))%mod
def modpow(m,n):
if n == 0:
return 1
if n % 2:
return ((modpow(m,n//2)**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... |
s166434915 | p04046 | Time Limit Exceeded | def combi(m,n):
child = 1
mom = 1
while n != 0:
child *= m
mom *= n
m -= 1
n -= 1
return child//mom
H,W,A,B = map(int,input().split())
mod = 10**9+7
ans = 0
x = 1
while x <= H - A:
ans += combi(x+B-2,min(x,B)-1)*combi(H-x+W-B-1,min(H-x+1,W-B)-1)
ans %= mod
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... |
s330058829 | p04046 | Time Limit Exceeded | h, w, a, b = [int(item) for item in input().split()]
MOD = 10**9 + 7
n = 2 * 10**5
def mod_pow(x, n):
ans = 1
while(n != 0):
if n & 1:
ans = ans * x % MOD
x = x * x % MOD
n = n >> 1
return ans
fac = [1] + [0] * n
fac_inv = [1] + [0] * n
for i in range(1, n+1):
fac[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... |
s790567081 | p04046 | Time Limit Exceeded | h,w,a,b=map(int,input().split())
l=[[0 for i in range (w)] for j in range (h)]
for i in range(w):
l[0][i]=1
for i in range(h-a):
l[i][0]=1
for i in range(1,h-a):
for j in range(1,w):
l[i][j]=l[i-1][j]+l[i][j-1]
for i in range(h-a,h):
l[i][b]=l[h-a-1][b]
for i in range(h-a,h):
for j in range(... | 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... |
s241259728 | p04046 | Time Limit Exceeded | import math
H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
def f(h, w):
return math.factorial(h+w-2) // (math.factorial(h-1) * math.factorial(w-1))
answer = 0
for i in range(B+1, W+1):
answer += f(H-A, i) * f(A, W-i+1)
answer %= MOD
print(int(answer)) | 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... |
s942471658 | p04046 | Time Limit Exceeded | H,W,A,B=map(int,input().split())
memo=[[1 for j in range(W)] for i in range(H)]
for i in range(1,H):
for j in range(W):
if i>=H-A and j <B:
memo[i][j]=0
elif j!=0:memo[i][j]=(memo[i-1][j]+memo[i][j-1])%(10**9+7)
print(memo[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... |
s676047627 | p04046 | Time Limit Exceeded | H,W,A,B=map(int,input().split())
memo=[[] for i in range(H)]
memo[0]=[1 for i in range(W)]
for i in range(1,H):
for j in range(W):
if i>=H-A and j <B:
memo[i].append(0)
elif j==0:
memo[i].append(1)
else:
memo[i].append((memo[i-1][j]+memo[i][j-1])%(10**9+7))
print(memo[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... |
s851486023 | p04046 | Time Limit Exceeded | height, width, a, b = [int(i) for i in input().split(' ')]
arrays = [[1] * width for _ in range(height)]
for i in range(-a, 0):
for j in range(0, b):
arrays[i][j] = 0
for i in range(height):
arrays[i] = [0] + arrays[i]
arrays = [[0] + [1] + [0] * (width - 1)] + arrays
for i in range(1, height+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... |
s746209214 | p04046 | Time Limit Exceeded | H, W, A, B = list(map(int, input().split()))
def combinations_count(n, r):
if n - r < r:
r = n - r
if r == 0:
return 1
if r == 1:
return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2, r + 1):
pivot = 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.