submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s006951128 | p04046 | Wrong Answer | import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
H, W, A, B = map(int, input().split())
mod = 10**9 + 7
ans = 0
for i in range(1,H-A+1):
if i == 1:
if W-B == 1:
ans += 1
else:
ans += combinations_count(W-B+H-2,W-B-1) % mod
els... | 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... |
s060828257 | p04046 | Wrong Answer | h,w,a,b = map(int,input().split())
l = [[1 for i in range(w)] for j in range(h-a)]
l += [[0]*b + [1]*(w-b) for i in range(a)]
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(a,h):
for j in range(b,w):
l[i][j]=l[i-1][j]+l[i][j-1]
print(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... |
s349974729 | p04046 | Wrong Answer | h, w, a, b = map(int,input().split())
mod = 10**9 + 7
def inv(x, p):
pp = p-2
ans = 1
while pp > 0:
if pp % 2 == 1:
ans = (ans * x) % p
x = (x ** 2) % p
pp //= 2
return ans
I = [1] + [inv(i, mod) for i in range(1, h+w+1)]
a0 = 1
a1 = 1
for i in range(w-b+a-1, 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... |
s337860284 | p04046 | Wrong Answer | from math import factorial
h, w, a, b = map(int, input().split())
MOD = 10**9+7
fact = [1]
# 累積乗を作る
for i in range(1, h+w-1):
fact.append(fact[-1] * i % MOD)
# 累積乗の逆元
inv_fact = [pow(fact[-1], MOD-2, MOD)] # x^(-1) = x^(10^9+5) % (10^9+7), フェルマーの小定理
for i in range(h+w-2, 0, -1): # xが最大の場合を求め、後ろ向きに計算していく
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... |
s641676698 | p04046 | Wrong Answer | from math import factorial
h, w, a, b = map(int, input().split())
MOD = 1000000007
ans = 0
for x in range(b, w):
t = (factorial(x+h-1-a) // (factorial(x) * factorial(h-1-a))) % MOD
ans += (t * (factorial((a-1+w-x-1)) // (factorial(w-x-1) * factorial(a-1))) % 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... |
s655506773 | p04046 | Wrong Answer | 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=4,4,2,2
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(result)
# 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... |
s444641787 | p04046 | Wrong Answer | from collections import deque
H,W,A,B=map(int,input().split())
# H,W,A,B=2,3,1,1
# H,W,A,B=10,7,3,4
array=[[0 for i in range(W)] for j in range(H)]
#進めないところ塗りつぶし+1埋め
for i in range(H):
for j in range(W):
if i==0 or j==0:
array[i][j]=1
if H-A<=i and j<B:
array[i][j]=-1
# arra... | 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... |
s003389139 | p04046 | Wrong Answer | 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])
| 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... |
s082351510 | p04046 | Wrong Answer | H,W,A,B=map(int,input().split())
m=[[0 for _ in range(W)] for _ in range(H)]
m[0][0]=1
for i in range(H):
for j in range(W):
if i<H-A or j>=B:
if i==0:
if j>=1:
m[i][j]=m[i][j-1]
else:
if j==0:
m[i][j]=m[i-1][j]
else:
m[i][j]=m[i-1][j]+m[i][j-1]
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... |
s995751272 | p04046 | Wrong Answer | def debug(l):
for i in l:
print(i)
h,w,a,b=map(int,input().split())
#メモ
dp=[[0 for i in range(w)]for j in range(h)]
#行けない場所は-1
for i in range(h-a,h):
for j in range(b):
dp[i][j]=-1
#1パターンしかないところを埋めていく
for i in range(a):
dp[i][0] = 1
for i in range(w):
dp[0][i] = 1
#debug(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... |
s418406992 | p04046 | Wrong Answer | CONST=10**9+7
H,W,A,B=map(int,input().split())
def kaizyo(num):
multi=1
for i in range(1,num+1):
multi*=i
return multi
sum=0
for i in range(0,W-B):
sum+=(kaizyo(H-A-1+B+i)%CONST/(kaizyo(H-A-1)*kaizyo(B+i)%CONST)%CONST)*(kaizyo(A-1+W-B-1-i)%CONST/(kaizyo(A-1)*kaizyo(W-B-1-i)%CONST)%CONST)
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... |
s641804406 | p04046 | Wrong Answer | H,W,A,B = map(int,input().split())
MOD = 10**9+7
L = [1]
for i in range(B,B+H-A-1):
L.append((L[-1]*i//(i-B+1))%MOD)
R = [1]
for i in range(W-B,W-B+H-1):
R.append((R[-1]*i//(i-W+B+1))%MOD)
ans = 0
for i in range(len(L)):
ans += (L[i]*R[-i-1])%MOD
print(ans%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... |
s909304811 | p04046 | Wrong Answer | # -*- coding: utf-8 -*-
# スペース区切りの整数の入力
H, W, A, B = map(int, input().split())
T = [[-1 for i in range(W)] for j in range(H)]
# 初期値 2次元テーブルを作成
T[0][1:] = [1 for k in range(W)]
for j in range(H):
T[j][0] = 1 if j>0 else 0
# 下からA個,左からB個の枠に対して0による塗りつぶし
for j in range(A):
T[H-1-j][:B] = [0 for k in range(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... |
s788859614 | p04046 | Wrong Answer | # -*- coding: utf-8 -*-
# スペース区切りの整数の入力
H, W, A, B = map(int, input().split())
T = [[-1 for i in range(W)] for j in range(H)]
S = 0
# 初期値 2次元テーブルを作成
for i in range(W-1):
T[0][i+1] = 1
for j in range(H-1):
T[j+1][0] = 1
T[0][0]=0
# 下からA個,左からB個の枠に対して0による塗りつぶし
for j in range(A):
for i in range(B):
T[H-1-j][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... |
s406660837 | p04046 | Wrong Answer | high, width, y, x = map(int, input().split())
def nCr(n, r):
return (((fact[n]*finv[n-r]%mod)*finv[r])%mod)
mod = 10**9 + 7
inv = mod - 2
maxn = high + width - 2
fact = [0] * (maxn+1)
finv = [0] * (maxn+1)
fact[0] = fact[1] = 1
finv[0] = finv[1] = 1
# 階乗を求める
for i in range(2, maxn+1):
fact[i] = (fact[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... |
s801067822 | p04046 | Wrong Answer | h, w, a, b = map( int, input().split() )
SIZE = h+w+2
MOD = 10**9 + 7
MOD_Farmer = 10**9+5
fact = [0] * SIZE
inv = [0] * SIZE
fact_inv = [0] * SIZE
# prepare --------------------------------
inv[0] = 0
inv[1] = 1
fact[0] = fact[1] = 1
fact_inv[0] = fact_inv[1] = 1
for i in range( 2, SIZE ):
fact[i] = fact[i-1] * 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... |
s092566115 | p04046 | Wrong Answer | h, w, a, b = map( int, input().split() )
SIZE = h+w+2
MOD = 10**9 + 7
MOD_Farmer = 10**9+5
fact = [0] * SIZE
inv = [0] * SIZE
fact_inv = [0] * SIZE
# prepare --------------------------------
inv[0] = 0
inv[1] = 1
fact[0] = fact[1] = 1
fact_inv[0] = fact_inv[1] = 1
for i in range( 2, SIZE ):
fact[i] = fact[i-1] * 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... |
s684820560 | p04046 | Wrong Answer | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 26 05:23:03 2019
@author: matsui
"""
import numpy as np
def kai(a,b):
ans=int(1)
for i in range(a,b-1,-1):
ans*=int(i)
if ans > 1e15: ans=int(ans%(1e9+7))
return int(ans)
def C(a,b):
#x=np.arange(b+1,a+1)
#y=np.arange(1,(a-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... |
s778578818 | p04046 | Wrong Answer | 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%(10**9+7)
ha_w = [func(h-a-1, i) for i in range(w)]
a_wb = [func(a-1, i) for i in range(w-b)]
ans = sum([ha_w[-1-i]*a_wb[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... |
s947101329 | p04046 | Wrong Answer | def main():
H, W, A, B = map(int, input().split())
DIV = 10**9+7
def my_pow(x, n):
ans = 1
while n > 0:
if (n&1) == 1:
ans = ans*x%DIV
x = x*x%DIV
n >>= 1
return ans%DIV
fact = [0]*(H+W+1)
inverse = [0]*(H+W+1)
inverse[0] = 1
fact[0] = 1
for i in range(1, H+W-A+1):
fact[i] = (fact[i-1]*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... |
s528405626 | p04046 | Wrong Answer | def main():
H, W, A, B = map(int, input().split())
H, W= H-1, W-1
DIV = 10**9+7
def my_pow(x, n):
ans = 1
while n > 0:
if (n&1) == 1:
ans = ans*x%DIV
x = x*x%DIV
n >>= 1
return ans%DIV
fact = [0]*(H+W+1)
inverse = [0]*(H+W+1)
inverse[0] = 1
fact[0] = 1
for i in range(1, H+W-A+1):
fact[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... |
s016468758 | p04046 | Wrong Answer | [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... |
s155670881 | p04046 | Wrong Answer | [h,w,a,b]=[int(_) for _ in input().split()]
import math
import functools
import operator
def p(x,y):
if x==0 or y==0: return 0
elif x==1 or y==1: return 1
if x>=y:
k=x-1
l=y-1
else:
k=y-1
l=x-1
return functools.reduce(operator.mul, [(k-i)//(l-i) for i in range(l)])
n=sum([p(i+1,b)*p(h-i,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... |
s872155476 | p04046 | Wrong Answer | [h,w,a,b]=[int(_) for _ in input().split()]
import math
import functools
import operator
def p(x,y):
if x==0 or y==0: return 0
elif x==1 or y==1: return 1
if x>=y:
k=x-1
l=y-1
else:
k=y-1
l=x-1
return functools.reduce(operator.mul, [(k-i)//(l-i) for i in range(l)])
n=sum([p(i+1,b)*p(h-i,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... |
s382142741 | p04046 | Wrong Answer | inputs = list(map(int, input().split()))
H,W,A,B = inputs
field = [[1 for i in range(W)] for i in range(H)]
for i in range(H-A-1,H):
for j in range(0,B):
field[i][j]=0
for i in range(1,H):
if i < H-A:
for j in range(1,W):
field[i][j]=field[i][j-1]+field[i-1][j]
else:
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... |
s597147465 | p04046 | Wrong Answer | inputs = list(map(int, input().split()))
H,W,A,B = inputs
field = [[1 for i in range(W)] for i in range(H)]
for i in range(H-A-1,H):
for j in range(0,B):
field[i][j]=0
for i in range(1,H):
if i < H-A:
for j in range(1,W):
field[i][j]=field[i][j-1]+field[i-1][j]
else:
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... |
s229962537 | p04046 | Wrong Answer | def comb(a, b):
b = min(b, a - b)
if b == 0:
return 1
f = 1
for i in range(1, b + 1):
f *= a + 1 - i
f //= i
f = f % (10**9+7)
return f
h, w, a, b = [int(v) for v in input().split()]
c = min(h - a - 1, w - b - 1)
ans = 0
#print(c)
#a1 = comb(b + h - a - 1, h - a - 1)
#a2 = comb(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... |
s002567554 | p04046 | Wrong Answer | import math
H, W, A, B = map(int, input().split())
mod = 10**9+7
def route(n, r):
return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
ans = 0
for i in range(B, W):
h1 = H-1-A
w1 = i
h2 = A-1
w2 = W-1-i
ans += route(h1+w1, w1) * route(h2+w2, ... | 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... |
s387362286 | p04046 | Wrong Answer | h,w,a,b=map(int,input().split())
mod=10**9+7
fact=[1]*(h+w+1)
for i in range(1,h+w+1):
fact[i]=(fact[i-1]*i)%mod
def cmb(a,b):
return fact[a]*pow(fact[b],mod-2,mod)*pow(fact[a-b],mod-2,mod)%mod
ans=0
for i in range(b,w):
ans+=cmb(h-a+i-1,i)*cmb(w-1-i+a-1,w-i-1)
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... |
s076649375 | p04046 | Wrong Answer | from numpy import array
from math import factorial
h,w,a,b=map(int,input().split())
h-=1
w-=1
a-=1
b-=1
mod=10**9+7
table=[factorial(i)%mod for i in range(h+w+1)]
def cmb(a,b):
return table[a]//table[a-b]//table[b]
migisita=[cmb(i+h-a-1,h-a-1)for i in range(b+1,w+1)]
hidarisita=[cmb(a+i-1,i-1)for i in range(1,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... |
s174617787 | p04046 | Wrong Answer | from sys import exit
H,W,A,B = [int(n) for n in input().split()]
MOD = 10**9+7
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
# print(H,W,A,B)
def modfact(n, m):
res=1
for i in range(2,n+1):
res*=i
res%=m
return res
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... |
s348832864 | p04046 | Wrong Answer | 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... |
s679640956 | p04046 | Wrong Answer | from sys import stdin
import sys
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7
input = stdin.readline
H, W, A, B = [int(x) for x in input().rstrip().split()]
factorial = [1]
for i in range(1, H+W):
factorial.append(factorial[i-1] * i % mod)
def power(x, y):
if y == 0:
return 1
elif y == 1:
return 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... |
s330664915 | p04046 | Wrong Answer | from sys import stdin
import sys
sys.setrecursionlimit(10000)
mod = 10 ** 9 + 7
input = stdin.readline
H, W, A, B = [int(x) for x in input().rstrip().split()]
def C(n, r):
return factorial[n] * (x_inv[r] * x_inv[n-r] % mod) % mod
factorial = [1]
for n in range(1, H+W):
factorial.append(factorial[n-1] * n % mod)
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... |
s249494466 | p04046 | Wrong Answer | H, W, A, B = list(map(int, input().split()))
# 事前計算 + 演算ごとに mod する
def solve():
# 組合せの計算用に階乗を事前計算しておく
MOD = 10 ** 9 + 7
FACT = [0] * (H + W + 1)
INV_FACT = [0] * (H + W + 1) # 逆元. 組合せの計算ごとにMODを取るため
FACT[0], INV_FACT[0] = 1, 1
for i in range(1, (H + W + 1)):
FACT[i] = (FACT[i - 1] * 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... |
s934721427 | p04046 | Wrong Answer | 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].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... |
s049051650 | p04046 | Wrong Answer | H, W, A, B = map(int, input().split())
A = H - A
B -= 1
#init 2d list
dp = [[0 for w in range(W)] for h in range(H)]
#assign 1 to 0 row and column
dp[0] = [1 for w in range(W)]
for h in range(0, H):
for w in range(0, W):
if w <= B and h >= A:
dp[h][w] = 0
else:
dp[h][w] = (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... |
s360650810 | p04046 | Wrong Answer | h,w,a,b=map(int,input().split())
mod=10**9+7
n=h+w+1
fc,inv=[1]*n,[1]*n
for i in range(1,n):
fc[i]=i*fc[i-1]%mod
inv[n-1]=pow(fc[n-1],mod-2,mod)
for i in range(n-1,0,-1):
inv[i-1]=inv[i]*i%mod
f=lambda a,b:fc[a+b]*inv[a]*inv[b]%mod
v=0
for i in range(b,w):
v+=f(h-a-1,i)*f(a-1,w-i-1)%mod
print(v)
| 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... |
s918505359 | p04046 | Wrong Answer | import math
from itertools import combinations
from collections import Counter
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 =... | 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... |
s165991490 | p04046 | Wrong Answer | 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) % mod
def combination(n, r):
result = fac[n] // (fac[r] * fac[n-r]) % mod
return result
for i in range(B, W):
ans += (combination(H - A - 1 + 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... |
s014225512 | p04046 | Wrong Answer | mod = 7+10**9
H,W,A,B=map(int,input().split())
def con(a,b):
if b==0:return 1
if a==b:return 1
x=1
for i in range(b):
x=(x*(a-i)/(i+1))%mod
x=int(x)
return x
def calc(x,y):
res = con(x+y-2,x-1)
return res
all = 0
for i in range(W-B):
x=i+1
k = (calc(B+x,H-A)*calc(A,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... |
s577511453 | p04046 | Wrong Answer | mod = 7+10**9
H,W,A,B=map(int,input().split())
def con(a,b):
x=1
for i in range(b):
x=(x*(a-i)/(i+1))%mod
x=int(x)
return x
def calc(x,y):
res = con(x+y-2,x-1)
return res
all = calc(H,W)
for i in range(B):
x=i+1
k = (calc(x,H-A)*calc(A,W-i))%mod
all=int((all-k)%mod)
print(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... |
s159566783 | p04046 | Wrong Answer | import math
f = math.factorial
MOD = 1000000007
H, W, A, B = map(int, input().split())
# 左上(H-A, B) -> 右上(H-A, W-B)、右下(A, W-B)
dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
def debug(dp):
return
print('--')
for row in dp:
print(' '.join('{:10d}'.format(c) for c in row))
def pattern(w, h):
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... |
s547810870 | p04046 | Wrong Answer | H, W, A, B = map(int, input().split())
ans = 0
MOD = 10**9 + 7
N = H + W - 2
fac = [1] * N
inv = [1] * N
# 階乗
for i in range(1, N):
fac[i] = (fac[i - 1] * i) % MOD
# 普通の逆元テーブル
for i in range(1, N):
inv[i] = pow(i, MOD-2, MOD)
def f(x, y):
ans = fac[x + y] * inv[x] * inv[y] % MOD
return ans
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... |
s295257167 | p04046 | Wrong Answer | # 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... |
s933815650 | p04046 | Wrong Answer | # -*- 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... |
s907120408 | p04046 | Wrong Answer | h, w, a, b = map(int, input().split())
m = 10**9 + 7
fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, w+h+5):
fac.append(fac[i-1] * i % m)
inv.append(m - inv[m%i] * (m/i) % m)
finv.append(finv[i-1] * inv[i] % m)
def nck(n, k):
if n < k:
return 0
if n < 0 or k < 0:
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... |
s948636477 | p04046 | Wrong Answer | h, w, a, b = map(int, input().split())
m = 10**9 + 7
f = []
F = 1
f.append(F)
for i in range(1, w+h+1):
F *= i
F %= m
f.append(F)
def permutations_count(n, r):
return f[n] // f[n-r] // f[r]
row = []
for i in range(h-a):
row.append(permutations_count(b+i, i))
ans = 0
for i in range(len(row)-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... |
s876646075 | p04046 | Wrong Answer | # E.py#
#K, N = map(int,input().split())
P = 10**9+7
H, W, A, B = map(int,"10 7 3 4".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 Exception('mo... | 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... |
s853337308 | p04046 | Wrong Answer | MOD = 10**9+7
from math import factorial
h, w, a, b = list(map(int, input().split()))
num_path = 0
facts_n = [1]
for i in range(1, h+w-1):
facts_n.append(i*facts_n[i-1]%MOD)
# print(facts_n[:10])
def get_path(n, r):
return facts_n[n]//(facts_n[n-r]*facts_n[r])
y, x = h-a, b+1
while(True):
path_0 = ge... | 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... |
s962791790 | p04046 | Wrong Answer | MOD = 10**9+7
from math import factorial
h, w, a, b = list(map(int, input().split()))
num_path = 0
facts_n = [1]
for i in range(1, h+w-1):
facts_n.append(i*facts_n[i-1]%MOD)
# print(facts_n[:10])
def get_path(n, r):
return facts_n[n]//(facts_n[n-r]*facts_n[r])
y, x = h-a, b+1
while(True):
path_0 = ge... | 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... |
s199677215 | p04046 | Wrong Answer | H, W, A, B = (int(i) for i in input().split())
def comb(n, k):
m = 1
if n < 2 * k:
k = n - k
for i in range(1, k + 1):
m = m * (n - i + 1) / i
return m
#H, W, A, B = (10, 7, 3, 4)
#H, W, A, B = (2, 3, 1, 1)
# http://gzlku.hatenablog.com/entry/2017/09/17/074653
r = 0
for i in range(H-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... |
s923937156 | p04046 | Wrong Answer | H, W, A, B = (int(i) for i in input().split())
#H, W, A, B = (2, 3, 1, 1)
# 初期化
# W行 H列
mat = [[0 for x in range(W)] for y in range(H)]
# AかつBに−1を代入
for y in range(H - A, H):
for x in range(0, B):
mat[y][x] = -1
# 歩ける数を代入
for y in range(H):
for x in range(W):
# 右端でも左端でもない
if (x != 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... |
s841946540 | p04046 | Wrong Answer | h,w,a,b = map(int,input().split())
dp = [[0 for _ in range(w)] for __ in range(h)]
dp[0] = [1 for i in range(w)]
mod = 10**9 + 7
for i in range(1,h):
for j in range(w):
if h-i <= a and j <= b-1:
continue
if j == 0:
dp[i][j] = dp[i][j-1] % mod
else:
dp[i][j] = (dp[i][j-1] + dp[i-1][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... |
s864221065 | p04046 | Wrong Answer | MOD = 10**9+7
N = 200000
p = [1] * (N+1)
q = [1] * (N+1)
for i in range(1, N+1):
p[i] = (p[i-1]*(i)%MOD)
q[0] = pow(p[-1], MOD-2, MOD)
for i in range(1, N+1):
q[i] = (N-i+1)*q[i-1]%MOD
q.reverse()
def nCk(n,k):
if k > n or n == 0:
return 0
elif k == 0:
return 1
else:
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... |
s697038378 | p04046 | Wrong Answer | def main():
"""
入力例2: 10 7 3 4
S......
.......
.......
.......
.......
.......
.......
xxxx...
xxxx...
xxxx..G
h-1,w-1だけ移動する
全通り - NGパターン
全通り:
(h-1 + w-1) C (h-1)
Sから左上のx(1)にたどり着くルート:
(H-A) C (H-A) = 1
(1)からゴールまでのルート: (A-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... |
s094201196 | p04046 | Wrong Answer | MOD = 10**9+7
w, h, a, b=map(int,input().split())
# n!、1/(n!)の用意
fact = [1]*300000
invfact = [1]*300000
for i in range(2,300000):
fact[i] = (fact[i-1] * i) % MOD
# フェルマーの小定理
invfact[i] = (invfact[i-1] * pow(i, MOD-2, MOD)) % MOD
def nCm(n,m):
return (fact[n]*invfact[m]*invfact[n-m])%MOD
# (0,0)->(w-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... |
s101132466 | p04046 | Wrong Answer | MOD = 10**9+7
w, h, a, b=map(int,input().split())
# n!、1/(n!)の用意
fact = [1]*300000
invfact = [1]*300000
for i in range(2,300000):
fact[i] = (fact[i-1] * i) % MOD
# フェルマーの小定理
invfact[i] = (invfact[i-1] * pow(i, MOD-2, MOD)) % MOD
def nCm(n,m):
return (fact[n]*invfact[m]*invfact[n-m])%MOD
# (0,0)->(w-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... |
s552247388 | p04046 | Wrong Answer | MOD = 10**9+7
w, h, a, b=map(int,input().split())
# n!、1/(n!)の用意
fact = [1]*200000
invfact = [1]*200000
for i in range(2,200000):
fact[i] = (fact[i-1] * i) % MOD
# フェルマーの小定理
invfact[i] = (invfact[i-1] * pow(i, MOD-2, MOD)) % MOD
def nCm(n,m):
return (fact[n]*invfact[m]*invfact[n-m])%MOD
# (0,0)->(w-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... |
s081620975 | p04046 | Wrong Answer | h, w, a, b = [int(i) for i in input().split()]
p = 10 ** 9 + 7
s = 0
fact = [1]
for i in range(1, h+w-2):
fact.append(fact[i-1] * i % p)
rfact = [(h+w-2) % p]
for i in range(h+w-1, 0, -1):
rfact.append(rfact[-1] * i % p)
rfact.reverse()
def comb(n, r):
return fact[n]//fact[n-r]%p//fact[r]%p
for i 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... |
s820987054 | p04046 | Wrong Answer | h, w, a, b = [int(i) for i in input().split()]
p = 10 ** 9 + 7
s = 0
fact = [1]
for i in range(1, h+w-2):
fact.append(fact[i-1] * i % p)
rfact = [(h+w-2) % p]
for i in range(h+w-1, 0, -1):
rfact.append(rfact[-1] * i % p)
rfact.reverse()
def comb(n, r):
return fact[n]//fact[n-r]//fact[r]%p
for i in 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... |
s801238295 | p04046 | Wrong Answer | import scipy.misc as scm
h, w, a, b = [int(i) for i in input().split()]
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) | 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... |
s888169468 | p04046 | Wrong Answer | def power_func(a,b,p):
"""a^b mod p を求める"""
if b==0: return 1
if b%2==0:
d=power_func(a,b//2,p)
return d*d %p
if b%2==1:
return (a*power_func(a,b-1,p ))%p
from math import factorial
H,W,A,B=map(int, input().split())
p=10**9+7
ans=0
X=[1]
Y=[1]
for i in range(H+W-2):
fact=factorial(i+1)%p
X+=[fa... | 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... |
s646384692 | p04046 | Wrong Answer | def power_func(a,b,p):
"""a^b mod p を求める"""
if b==0: return 1
if b%2==0:
d=power_func(a,b//2,p)
return d*d %p
if b%2==1:
return (a*power_func(a,b-1,p ))%p
from math import factorial
H,W,A,B=map(int, input().split())
p=10**9+7
ans=0
X=[1]
Y=[1]
for i in range(H+W-2):
fact=factorial(i+1)%p
X+=[fa... | 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... |
s708225848 | p04046 | Wrong Answer | 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) | 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... |
s200734446 | p04046 | Wrong Answer | import math
def nCr(n, r):
f = math.factorial
return f(n) / f(r) / f(n-r)
def solv(H, W, A, B):
D = 10**9 + 7
h = H - 1
w = W - 1
total = nCr(h+w, h)
i = h - A
forbidden = 0
for j in range(B):
forbidden += nCr(i+j, i) * nCr((h-i-1)+(w-j), h-i-1)
return int(total - 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... |
s287434660 | p04046 | Wrong Answer | import math
def nCr(n, r):
f = math.factorial
return f(n) / f(r) / f(n-r)
def solv(H, W, A, B):
h = H - 1
w = W - 1
total = nCr(h+w, h)
i = h - A
forbidden = 0
for j in range(B):
forbidden += nCr(i+j, i) * nCr((h-i-1)+(w-j), h-i-1)
return int(total - forbidden)
H, W, 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... |
s442740200 | p04046 | Wrong Answer | mod=1000000007
#mod=1777777777
pi=3.141592653589
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for se... | 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... |
s948533180 | p04046 | Wrong Answer | import math
def c_calc(a,b):
return math.factorial(a)/math.factorial(a-b)/math.factorial(b)
def math_calc(h,w):
return c_calc(h-1+w-1,h-1)
if __name__ == '__main__':
H,W,A,B = map(int,raw_input().split())
all_ans = 0
for x in range(B+1,W+1):
all_ans += math_calc(H-A,x) * math_calc(A,W-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... |
s814462802 | p04046 | Wrong Answer | h, w, a, b = map(int, raw_input().split())
mod = 10**9+7
ans = 0
mod_fact = [1]
for i in range(1,h+w-2):
mod_fact.append((i*mod_fact[i-1])%mod)
factinv = [1] * (h+w-2)
factinv[h+w-3] = pow(mod_fact[h+w-3],(mod-2),mod)
for i in reversed(range(2,h+w-3)):
factinv[i] = (factinv[i+1] * (i+1))%mod
def C(n,r):
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... |
s729479948 | p04046 | Wrong Answer | import itertools,math,bisect,pprint,sys
h, w, a, b = map(int, raw_input().split())
mod = 10**9+7
ans = 0
def mod_fact(n):
res = 1
for i in range(1,n+1):
res *= i
res %= mod
return res
def divmod(n):
return pow(mod_fact(n),(mod-2),mod)
def C(n,r):
return mod_fact(n)*divmod(n-r)*divmod... | 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... |
s286488491 | p04046 | Wrong Answer | H,W,A,B = [int(n) for n in input().split(" ")]
answers = []
for total in range(B,W):
disp,div = 1,1
for n in range(min(H-A,total + 1),total+(H-A)):
if div >= max(H-A,total + 1):
disp = (disp * n) % (10**9 + 7)
else:
disp = ((disp * n) % (10**9 + 7) // div)
div... | 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... |
s365728812 | p04046 | Wrong Answer | import math
def nCr(n, r):
return (int(math.factorial(n)) // int(math.factorial(r)) // int(math.factorial(n - r))) % C
C = int(1e9) + 7
h, w, a, b = [int(x) for x in input().split()]
ans = 0
for i, j in zip(range(b, w), range(w - 1, b - 1, -1)):
ans = (ans + nCr(i + h - a - 1, h - a - 1) * nCr(j - 2, 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... |
s306783919 | p04046 | Wrong Answer | import math
def nCr(n, r):
return (int(math.factorial(n)) // int(math.factorial(r)) // int(math.factorial(n - r))) % C
C = int(1e9) + 7
h, w, a, b = [int(x) for x in input().split()]
row = [nCr(i + h - a - 1, h - a - 1) for i in range(b, w)]
row2 = reversed([nCr(i, i - b) for i in range(b, w)])
ans = sum([x * 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... |
s978894714 | p04046 | Wrong Answer | 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... |
s646226780 | p04046 | Wrong Answer | MOD = 10**9+7
H, W, A, B = map(int, raw_input().split())
dp = [1]*W
b = 1
for h in xrange(H-1):
print dp
if h == H-A-1:
print "!"
dp = dp[B:]
for w in xrange(1, len(dp)):
dp[w] += dp[w-1]%MOD
print dp[-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... |
s086013474 | p04046 | Wrong Answer | h, w, a, b = map(int, raw_input().split())
m = [1 for _ in range(w)]
for _ in range(h - a - 1):
for j in range(1, w):
m[j] = m[j] + m[j - 1]
for _ in range(a):
for j in range(b + 1, w):
m[j] = m[j] + m[j - 1]
print m[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... |
s779908558 | p04046 | Wrong Answer | h, w, a, b = map(int, raw_input().split())
m = [[0 for i in range(w)] for j in range(h)]
for i in range(a):
for j in range(b):
m[h - i - 1][j] = -1
for i in range(w):
m[0][i] = 1
for i in range(h - a):
m[i][0] = 1
for i in range(a):
m[h - i - 1][b] = 1
for i in range(1, h):
for j in range(1, w):
if m[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... |
s056666436 | p04046 | Time Limit Exceeded | # H, W, A, Bの入力受付
H, W, A, B = map(int, input().split())
# 2次元リストの要素に上のマスと左のマスにある数字を足した数を順次代入
MAP = []
for i in range(H):
if i != 0 and i <= (H - A - 1):
# 2行目以降の1列目には1を入力する
MAP.append([1])
else:
# 1行目と下からAマス以内には0を入力する
MAP.append([0])
for j in range(W):
# 1列目には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... |
s431257875 | p04046 | Time Limit Exceeded | def dfs(x,y):
global ans
if not(0<=x<h) or not(0<=y<w) or maze[x][y]=='#':
return
if maze[x][y]=='g':
ans += 1
return
dfs(x+1,y)
dfs(x,y+1)
h,w,a,b = map(int,input().split())
maze = [['.' for i in range(w)] for j in range(h)]
for i in range(1,a+1):
for j in range(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... |
s416753219 | p04046 | Time Limit Exceeded | import numpy as np
h,w,a,b = map(int,input().split())
dp = np.array([[1] * w] * h)
dp[h-a:,:b] = 0
for i in range(1,h-a):
for j in range(1,w):
dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % (10 ** 9 + 7)
for i in range(h-a,h):
for j in range(b,w):
dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % (10 ** 9 + 7)
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... |
s224632096 | p04046 | Time Limit Exceeded | from operator import mul
from functools import reduce
from scipy.special import comb
# 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
# def cmb(n, r):
# r = min(n-r, r)
# if r == 0:
# return 1
# over = reduce(mul, 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... |
s922903551 | p04046 | Time Limit Exceeded | import math
h,w,a,b=map(int,input().split())
kei=math.factorial(h+w-2)//(math.factorial(h-1)*math.factorial(w-1))
cc=0
for i in range(a):
c=math.factorial(h-1+b-i-1)//(math.factorial(b-1)*math.factorial(h-i-1))
bc=math.factorial(w-b-1+i)//(math.factorial(i)*math.factorial(w-b-1))
cc+=c*bc
ans=kei-cc
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... |
s987200150 | p04046 | Time Limit Exceeded | def combi(n, r):
import math
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def main():
import math
h,w,a,b=map(int,input().split())
h-=1
w-=1
a-=1
b-=1
N=combi(w-b-1+h,h)
h1=h-1
while h1>a:
N+=combi(h-h1+b,b)*combi(h1+w-b-1,h1)
h1-=... | 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... |
s908233789 | p04046 | Time Limit Exceeded | 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... |
s967491640 | p04046 | Time Limit Exceeded | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def _main():
h, w, a, b = get_ints()
from collections import defaultdict
dd = defaultdict(lambda: 1)
for i in range(1, h-a):
for j in range(1, w):
dd... | 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... |
s125266280 | p04046 | Time Limit Exceeded | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
from collections import defaultdict
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def _main():
h, w, a, b = get_ints()
list2 = defaultdict(int)
for j in range(0, w):
list2[0, j] = 1
for i in range(1, h-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... |
s023213381 | p04046 | Time Limit Exceeded | from math import factorial
def power(a, b, p): #a^b (mod p)を求める #二分累乗法を使う
if b == 0:
return 1
elif b % 2 == 0:
return power(a, b//2, p) ** 2 % p
else:
return power(a, b//2, p) ** 2 * a % p
H, W, A, B = map(int, input().split())
C = H - A
D = W - B
p = 1000000007
b = power(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... |
s084101340 | p04046 | Time Limit Exceeded | from math import factorial
def power(a, b, p): #a^b (mod p)を求める #二分累乗法を使う
if b == 0:
return 1
elif b % 2 == 0:
x = power(a, b//2, p)
return x ** 2 % p
elif b % 2 == 1:
y = power(a, b-1, p)
return a * y % p
H, W, A, B = map(int, input().split())
C = H - A
D = W - B
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... |
s334175637 | p04046 | Time Limit Exceeded | from math import factorial
def power(a, b, p): #a^b (mod p)を求める #二分累乗法を使う
if b == 0:
return 1
elif b % 2 == 0:
x = power(a, b//2, p)
return x ** 2 % p
elif b % 2 == 1:
y = power(a, b-1, p)
return a * y % p
H, W, A, B = map(int, input().split())
C = H - A
D = W - B
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... |
s774116086 | p04046 | Time Limit Exceeded | def power(a, b, p): #a^b (mod p)を求める #二分累乗法を使う
if b == 0:
return 1
elif b % 2 == 0:
x = power(a, b//2, p)
return x ** 2 % p
elif b % 2 == 1:
y = power(a, b-1, p)
return a * y % p
def comb(a, b, p): #(a+b)!/a!b! (mod p)を求める #power関数を使う
from math import 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... |
s366276911 | p04046 | Time Limit Exceeded | import math
h,w,a,b = map(int, input().split())
result = 0
for i in range(b,w):
result += ((math.factorial((i)+(h-a-1))) // (math.factorial(i) * math.factorial(h-a-1))) * ((math.factorial((w-i-1)+(a-1))) // (math.factorial(w-i-1)*math.factorial(a-1)))
result = result%(10**9 + 7)
print(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... |
s836347975 | p04046 | Time Limit Exceeded | from functools import*
from sys import *
import sys
sys.setrecursionlimit(10**7)
@lru_cache(None)
def f(n):
if n < 2:
return 1
else:
return n * (f(n - 1))
MOD = 10**9 + 7
def c(a, b):
return (f(a) // (f(b) * f(a - b))) % MOD
h, w, hh, ww = map(int, input().split())
total = 0
for i 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... |
s962748004 | p04046 | Time Limit Exceeded | h,w,a,b=map(int, input().split())
mod=1000000007
matx=[[0 for y in range(w)] for x in range(h)]
for j in range(w):
matx[0][j]=1
for i in range(h-a):
matx[i][0]=1
for i in range(h-a):
for j in range(w):
matx[i][j]=(matx[i-1][j]+matx[i][j-1])%mod
for i in range(h-a, h):
for j in range(b, 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... |
s117168651 | p04046 | Time Limit Exceeded | # a^n mod p
def beki_mod(a, n, p):
ans = 1
n = format(n, "b")
for i in range(len(n)):
ans = ans * ans % p
if n[i] == "1":
ans = ans * a % p
return ans
# a! mod p
def kaijo_mod(a, p):
ans = 1
while a > 0:
ans = ans * a % p
a -= 1
return 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... |
s122979478 | p04046 | Time Limit Exceeded | # a^n mod p
def beki_mod(a, n, p):
ans = 1
n = format(n, "b")
for i in range(len(n)):
ans = ans * ans % p
if n[i] == "1":
ans = ans * a % p
return ans
# nCr = n * (n -1) * ... * (n - r + 1) / r!
# a^(-1) mod p = a^(p -2) mod p
def combi_mod(n, r, p):
bunshi = 1
bumbo... | 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... |
s315625133 | p04046 | Time Limit Exceeded | def conbi(n, r):
bunbo = 1
bunshi = 1
if n / 2 < r:
r = n - r
while r > 0:
bunbo *= r
bunshi *= n
r -= 1
n -= 1
return bunshi // bunbo
def conbi_mod(n, r):
return conbi(n, r) % (10 ** 9 + 7)
H, W, A, B = map(int, input().split())
if B < W / 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... |
s570341617 | 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
H, W, A, B = map(int, input().split())
count = 0
mid_point_yoko = B-1
end_point_yoko = W-B-1
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... |
s747776588 | p04046 | Time Limit Exceeded | def numberOfWays(h, w, a, b):
dp = [0] * h
for i in range(h):
dp[i] = [0] * w
for i in range(h):
if h - a > i:
dp[i][0] = 1
for j in range(w):
dp[0][j] = 1
for i in range(1, h):
for j in range(1, w):
if h - a > i or b <= j:
dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
return 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... |
s041069274 | p04046 | Time Limit Exceeded | H,W,A,B=map(int,input().split())
M=H-A
N=W-B
import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a=B-1
b=H+N-2
c=N-1
max1=H+W
fact=math.factorial(max1)
mod=fact%(10**9+7)
mod_inv=mod**(10**9+5)%(10**9+7)
list1=[[max1mod,max1mod_inv]]
for i in range(max1):
fact=fac... | 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.