submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s261480853
p04046
Runtime Error
from operator import mul from functools import reduce def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % p p = 10 ** 9 + 7 N = 10 ** 5 fact = [1, 1] # fact[n] = (n! mod p) factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) 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...
s235834284
p04046
Runtime Error
from sys import stdin from operator import itemgetter ##stdin = open("sample.txt") H,W,A,B = [int(x) for x in stdin.readline().rstrip().split()] def fact(a): if a == 0: return 1 elif a == 1: return a else: return a * fact(a-1) path_list = list(range(W-B)) path_list2 = list(range(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...
s922047891
p04046
Runtime Error
from sys import stdin from operator import itemgetter #stdin = open("sample.txt") H,W,A,B = [int(x) for x in stdin.readline().rstrip().split()] def fact(a): if a == 1: return a return a * fact(a-1) path_list = list(range(W-B)) path_list2 = list(range(0)) path_list.reverse() for path in path_list: ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s575061516
p04046
Runtime Error
H, W, A, B = list(map(int, input().split())) up = [[0]*W for i in range(H-A)] down = [[0]*(W-B) for i in range(A)] #上側ここから for i in range(1, W): up[0][i] = 1 for j in range(1, H-A): up[j][0] = 1 for i in range(1, H-A): for j in range(1, W): up[i][j] = up[i-1][j] + up[i][j-1] #下側ここから down[0][0] = up[H-(A+1)][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...
s292953273
p04046
Runtime Error
import sys mod = pow(10, 9) + 7 sys.setrecursionlimit(pow(10, 8)) def power(x, y): if y == 0: return 1 elif y == 1 : return x % mod elif y % 2 == 0 : return power(x, y//2)**2 % mod else: return power(x, (y-1)//2)**2 * x % mod def mul(a, b): return ((a % mod) * (b % mod)) % mod def div(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...
s128645716
p04046
Runtime Error
import sys import numpy as np readline = lambda:sys.stdin.readline().rstrip() def solve(H,W,A,B): a = np.zeros([H,W], dtype=np.int32) a[:-A, 0] = 1 a[0, 1:] = 1 #[1-B) for y in range(1, H-A): a[y, 1:] += a[y-1, 1:] for x in range(1, W): a[y, x] = np.sum(a[y, x-1:x+1...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s784836799
p04046
Runtime Error
import fractions H,W,A,B=map(int,input().split()) mod =10**9+7 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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s820378045
p04046
Runtime Error
import math 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...
s543108779
p04046
Runtime Error
H,W,A,B=map(int,input().split()) def C(n,m): C=1 for k in range(m): C = C*(n+m-k)/(m-k) return 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) answer = (Total-dame)%(10**9+7) 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...
s438115515
p04046
Runtime Error
H,W,A,B=map(int,input().split()) H=H-1 W=W-1 A=A-1 B=B-1 def bikkuri(n): m=1 if n >1: for k in range(1,n+1): m = m *k return m def C(n,m): return bikkuri(n+m)/bikkuri(n)/bikkuri(m) Total = C(H,W) dame = 0 for k in range(0,B+1): dame += C(k,H-A-1)*C(W-k,A) answer = (Total-dame)%(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...
s834530172
p04046
Runtime Error
import math h, w, a, b = map(int, input().split()) count = 0 def combination(n, r) : num_1 = 1 num_2 = 1 for j in range(n-r) : num_1 *= (n-j) num_2 *= (j+1) num_ans = int(num_1 / num_2) return num_ans for i in range(b) : n1 = h-a+i-1 r1 = i n2 = w+a-i-2 r2 = 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...
s663411055
p04046
Runtime Error
import math # 10, 7, 3, 4 H, W, A, B = map(int, input().split()) # 通らなければいけない点を算出する need = [[B, i] for i in range(1, H-A+1)] ans = 0 for each in need: # 通らなければいけない点までの計算 left = each[0] - 1 top = each[1] - 1 C1 = (math.factorial(top+left))/(math.factorial(top)*math.factorial(left)) # それ以降の計算 ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s816031366
p04046
Runtime Error
mod = 10**9 + 7 h, w, a, b = map(int, input().split()) fact = [1] * (h + w + 1) invf = [1] * (h + w + 1) invn = [1] * (h + w + 1) for i in range(1, h + w + 1): fact[i] = fact[i-1] * i % mod invn[i] = -invn[mod % i] * (p // i) % mod invf[i] = invf[i-1] * invn[i] % mod count = 0 for i in range(min(h-a, w-b)): c...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s856589410
p04046
Runtime Error
import math as m import sys s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((w-b))) sum2+=sum1 print(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...
s448258756
p04046
Runtime Error
import math as m import sys from tkinter import * s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((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...
s140873800
p04046
Runtime Error
import math as m import sys s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((w-b))) sum2+=sum1 print(su...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s560988805
p04046
Runtime Error
import math as m import sys from tkinter import * s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((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...
s179496022
p04046
Runtime Error
import math h, w, a, b = map(int, input().split()) st1 = math.factorial(h+w) / (math.factorial(h) * math.factorial(w)) st2 = math.factorial(a+b) / (math.factorial(a) * math.factorial(b)) total = st1 - st2 wari = 10**9 + 7 print(total % wari)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s899456145
p04046
Runtime Error
h, w, a, b = map(int, input().split(' ')) MOD = 10**9 + 7 MAX = int(1.8*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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s372071832
p04046
Runtime Error
import math h, w, a, b = map(int, input().split(' ')) MOD = 10**9 + 7 def ncr(n, r): f = math.factorial return f(n) / f(r) / f(n-r) r = 0 for i in range(b, w): y1 = h - a - 1 x1 = i y2 = a - 1 x2 = w - i - 1 p = (ncr(x1 + y1, x1) * ncr(x2 + y2, x2)) % MOD r = (r + p) % MOD print(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...
s706472964
p04046
Runtime Error
h,w,a,b= map(int,input().split()) mod=10**9+7 f=[1] for i in range(h+w): f.append(f[i]*(i+1)%mod) def comb(n,r,p): return f[n]*pow(f[r],p-2,p)*pow(f[n-r],p-2,p)%p ans=0 for i in range(w-b): ans+=comb(h-a+b-1+i,b+i,mod)*comb(h+a-b-2-i,a-1,mod)%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...
s242719814
p04046
Runtime Error
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(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...
s437969794
p04046
Runtime Error
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(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...
s601560542
p04046
Runtime Error
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(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...
s643776801
p04046
Runtime Error
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(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...
s601456353
p04046
Runtime Error
import math h,w,a,b =map(int,input().split()) ans = 0 area1 = b-1 area2 = w+h-b-2 for j in range(h-a): ans1 = math.factorial(area1+j)/(math.factorial(area1)*math.factorial(j)) ans2 = math.factorial(area2-j)/(math.factorial(area2-h+1)*math.factorial(h-1-j)) ans += ans1*ans2 print(int(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...
s688303376
p04046
Runtime Error
import math h,w,a,b =map(int,input().split()) ans = 0 area1 = b-1 area2 = w+h-b-2 for j in range(h-a): ans1 = math.factorial(area1+j)/(math.factorial(area1)*math.factorial(j)) ans2 = math.factorial(area2-j)/(math.factorial(area2-h+1)*math.factorial(h-1-j)) ans += ans1*ans2 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...
s014931963
p04046
Runtime Error
nums = input().split() H = int(nums[0]) W = int(nums[1]) A = int(nums[2]) B = int(nums[3]) from math import factorial #全体 total = factorial(H + W -2) / factorial(W-1) / factorial(H - 1) #侵入不可 K = 1 forbidden = 0 while K < B + 1: x1 = factorial(H-A+K-2) / factorial(K-1)/factorial(H-A-1) x2 = factorial(W-K+A-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...
s925817134
p04046
Runtime Error
nums = input().split() H = int(nums[0]) W = int(nums[1]) A = int(nums[2]) B = int(nums[3]) from math import factorial #全体 total = factorial(H + W -2) / factorial(W-1) / factorial(H - 1) #侵入不可 K = 1 forbidden = 0 while K < B + 1: x1 = factorial(H-A+K-2) / factorial(K-1)/factorial(H-A-1) x2 = factorial(W-K+A-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...
s228866486
p04046
Runtime Error
import math HWAB=input().split() H=int(HWAB[0]) W=int(HWAB[1]) A=int(HWAB[2]) B=int(HWAB[3]) temp1=0 temp2=0 goukei=0 for i in range(H-A): temp1=int(math.factorial(i+B-1)/math.factorial(i)/math.factorial(B-1)) temp2=int(math.factorial(W-B-1+H-i-1)/math.factorial(W-B-1)/math.factorial(H-i-1)) goukei+=temp1...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s965210467
p04046
Runtime Error
def main(): H, W, A, B = map(int, input().split()) mod = 10**9 + 7 ans = 0 # 予め階乗を計算しておく f = [1] for i in range(H+W-B): f.append(f[i]*(i+1)%mod) # 組み合わせ関数 def comb_mod(n, r, p): return f[n] * pow(f[r], p-2, p) * pow(f[n-r], p-2, p) for i in range(H-A): 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...
s921175709
p04046
Runtime Error
def main(): H, W, A, B = map(int, input().split()) mod = 10**9 + 7 ans = 0 # 予め階乗を計算しておく f = [1] for i in range(H+W-B): f.append(f[i]*(i+1)%mod) # 組み合わせ関数 def comb_mod(n, r, p): return f[n] * pow(f[r], p-2, p) * pow(f[n-r], p-2, p) for i in range(H-A): 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...
s376659928
p04046
Runtime Error
n=200000 def pf(x,y,p): if y==0: return 1 if y%2==0: d=pf(x,y//2,p) return d*d%p if y%2==1: return (x*pf(x,y-1,p))%p facl=[1] for i in range(1,n+2): facl.append(facl[i-1]*i%mod) invl=[1]*(n+2) for i in range(1,n+2): invl[i]=pf(facl[i],mod-2,mod) def comb(x,k): if x<0 or k<0 or x<k: return 0 if...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s742134924
p04046
Runtime Error
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...
s953538159
p04046
Runtime Error
h,w,a,b = map(int, input().split()) def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = h+w g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-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...
s267064690
p04046
Runtime Error
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()) prev_com1 = 0 ans = 0 for i in range(h-a): com1 = cmb(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...
s016760980
p04046
Runtime Error
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()) h-a prev_com1 = 0 ans = 0 for i in range(h-a): com1 = cm...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s847609693
p04046
Runtime Error
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,H-A): P = f(i,B+1) Q = f(H-i+1,W-B) T = T + P*Q print(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...
s536167901
p04046
Runtime Error
# -*-coding: utf-8 -*- import math #マス目と通れないマスの入力 h,w,a,b = map(int,input().split()) ha = h-a total = 0 for i in range(ha): right = b-1 down = i first = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) right = w-b-1 down = h-i-1 last = math.factorial(right+down) / (math.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...
s492846214
p04046
Runtime Error
# -*-coding: utf-8 -*- import math #マス目と通れないマスの入力 h,w,a,b = map(int,input().split()) ha = h-a total = 0 for i in range(ha): right = b-1 down = i first = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) right = w-b-1 down = h-i-1 last = math.factorial(right+down) / (math.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...
s686889419
p04046
Runtime Error
# -*-coding: utf-8 -*- import math #マス目と通れないマスの入力 h,w,a,b = map(int,input().split()) ha = h-a total = 0 for i in range(ha): right = b-1 down = i first = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) right = w-b-1 down = h-i-1 print("right:"+str(right)+"down:"+str(down)) last ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s887589847
p04046
Runtime Error
height, width, disabledHeight, disabledWidth = map(int, input().split()) def getPattern(x, y): if (x <= disabledWidth) and (y > height - disabledHeight): return 0 if (x == 1) or (y == 1): return 1 return getPattern(x-1, y) + getPattern(x, y-1) print(getPattern(width, height) % (pow(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...
s055718564
p04046
Runtime Error
height, width, disabledHeight, disabledWidth = map(int, input().split()) def getPattern(x, y): if (x <= disabledWidth) and (y > height - disabledHeight): return 0 if (x == 1) or (y == 1): return 1 return getPattern(x-1, y) + getPattern(x, y-1) print(getPattern(width, height))
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s086637085
p04046
Runtime Error
height, width, disabledHeight, disabledWidth = map(int, input().spilit()) def getPattern(x, y): if (x == 1) or (y == 1): return 1 if (x <= disabledWidth) or (y > height - disabledHeight): return 0 return getPattern(x-1, y) + getPattern(x, y-1) print(getPattern(width, height))
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s936004910
p04046
Runtime Error
h, w, a, b = map(int, input().split()) mod = 1000000007 stairs = [1] for i in range(1, h+w+1): stairs.append(stairs[i-1]*i%mod) inverse_stairs = [0]*(h+w) inverse_stairs[h+w-1] = modpow(stairs[h+w-1], mod-2) for i in range(h+w-2, -1, -1): inverse_stairs[i] = inverse_stairs[i+1] * (i+1) % mod def modpow(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...
s004536274
p04046
Runtime Error
import fractions import math MOD = math.pow(10, 9) + 7 def calc_routes(dx, dy): if dx == 0 or dy == 0: return 1 else: return int(fractions.Fraction( math.factorial(dx + dy), math.factorial(dx) * math.factorial(dy) )) def check(h, w, a, b): p = (b + 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...
s376865170
p04046
Runtime Error
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // (math.factorial(a) * math.factorial(b)) p2end = math.factorial(c + b) // (math.factorial(c) * math.factorial(d)) return (start2p * p2end) % MOD def main(): h, w, a, b = map(int, i...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s966576965
p04046
Runtime Error
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // (math.factorial(a) * math.factorial(b)) p2end = math.factorial(c + b) // (math.factorial(c) * math.factorial(d)) return (start2p * p2end) % MOD def main(): h, w, a, b = map(int, i...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s067206608
p04046
Runtime Error
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // math.factorial(a) // math.factorial(b) p2end = math.factorial(c + b) // math.factorial(c) // math.factorial(d) return (start2p * p2end) % MOD def main(): h, w, a, b = map(int, inp...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s063431401
p04046
Runtime Error
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // (math.factorial(a) // math.factorial(b)) p2end = math.factorial(c + b) // (math.factorial(c) // math.factorial(d)) return (start2p * p2end) % MOD def main(): h, w, a, b = map(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...
s395031511
p04046
Runtime Error
from math import gamma cnt=0 h,w,a,b=map(int,input().split()) for k in range(0,h-a): cnt+= (int((gamma(b+k)*gamma(h+w-k-b-1))/(gamma(k+1)*gamma(b)*gamma(w-b)*gamma(h-k))))//(10^9+7) print(cnt)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s239974360
p04046
Runtime Error
class Queue: def __init__(self, data=[]): self.data = data def enqueue(self, x): self.data.append(x) def dequeue(self): return self.data.pop(0) def is_Empty(self): if len(self.data) == 0: return True else: return False mod = 1000000007...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s863461232
p04046
Runtime Error
h,w,a,b =map(int,input().split()) mod = 10**9+7 nfact_l = [1 for i in range(h+w+1)] def nfact_mod(n0,mod0): for i in range(1,len(nfact_l)): nfact_l[i] *= (nfact_l[i-1]*i)%mod nfact_mod(h+w+1,mod) #二分累乗法 あとで使う def powfunc_mod(n0,r0,mod0): ans0 = 1 r0 = bin(r0)[:1:-1] for i in r0: if 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...
s993977273
p04046
Runtime Error
import math H, W, A, B = map(int,input().split()) ans = 0 MOD = 10**9+7 for i in range(H-A): first = (math.factorial(B-1+i)/(math.factorial(B-1)*math.factorial(i))) % MOD last = (math.factorial(W+H-B-i-2)%MOD/(math.factorial(W-B-1)*math.factorial(H-i-1))) % MOD ans += int(first*last) 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...
s867515855
p04046
Runtime Error
H,W,A,B = map(int,input().split()) mod = 10**9 + 7 f = [1] for i in range(H+W): f.append(f[i]*(i+1)%mod) def comb(A,B,mod): return f[A] * pow(f[B],mod-2,mod) * pow(f[a-b],mod-2,mod) % mod res = 0 for i in range(B,W): res += comb(H-A+i-1,i,mod) * comb(A+W-i-2,A-1,mod) % mod print(res%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...
s729234961
p04046
Runtime Error
import numpy as np H, W, A, B = map(int, input().split()) p = int(10e9+7) D = np.zeros((H,W), dtype=int) D[(H-A):, :B] = -1 D[0,0] = 1 u = 0 l = 0 for i in range(H): for j in range(W): if D[i,j] == 0: if i == 0: u = 0 else: u = D[i-1,j] if...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s456311832
p04046
Runtime Error
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)/(kaizyo(H-A-1)*kaizyo(B+i))%CONST)*(kaizyo(A-1+W-B-1-i)/(kaizyo(A-1)*kaizyo(W-B-1-i))%CONST) print(int(sum%CONST))
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s565017487
p04046
Runtime Error
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)/(kaizyo(H-A-1)*kaizyo(B+i)))*(kaizyo(A-1+W-B-1-i)/(kaizyo(A-1)*kaizyo(W-B-1-i))) print(int(sum%(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...
s868581199
p04046
Runtime Error
import sys import math def input(): return sys.stdin.readline()[:-1] h,w,a,b=map(int,input().split()) mod=10**9+7 def c_c(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) ans=c_c(h+w-2,w-1) for i in range(a): ans-=c_c(h-a+b-1,h-a+i)*c_c(a+w-b-1,a-i-1) # print(c_c(h-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...
s713361936
p04046
Runtime Error
h,w,a,b=map(int,input().split())m=10**9+7;f=[1] for i in range(h+w):f+=[f[-1]*(i+1)%m] def comb(a,b,m):return f[a]*pow(f[b],m-2,m)*pow(f[a-b],m-2,m)%m x=0 for i in range(b,w):x+=comb(h-a+i-1,i,m)*comb(a+w-i-2,a-1,m)%m print(x%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...
s158955275
p04046
Runtime Error
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: s = powmod(a, int(n/2), m) temp...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s900339276
p04046
Runtime Error
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 if n%2 == 0: temp = (powmod(a, n/2, m) ** 2) % m return temp else: temp = (((powmod(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...
s880295885
p04046
Runtime Error
high, width, y, x = map(int, input().split()) import math route = 0 for i in range(1,high-y+1): if i != high-y: route += ((math.factorial(x+i-1)/(math.factorial(x)*math.factorial(i-1)))%(10**9+7))*((math.factorial(width-x-2+high-i)/(math.factorial(width-x-2)*math.factorial(high-i))))%(10**9+7) 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...
s807383653
p04046
Runtime Error
nCr = {} def cmb(n, r): if r == 0 or r == n: return 1 if r == 1: return n if (n,r) in nCr: return nCr[(n,r)] nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1) return nCr[(n,r)] h, w, a, b = map( int, input().split() ) ans = 0 mod_parent = 10**9 + 7 for i in range( 1, w-b ) : ans += ( cmb( 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...
s901816297
p04046
Runtime Error
nCr = {} def cmb(n, r): if r == 0 or r == n: return 1 if r == 1: return n if (n,r) in nCr: return nCr[(n,r)] nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1) return nCr[(n,r)] h, w, a, b = map( int, input().split() ) ans = 0 mod_parent = 10**9 + 7 for i in range( a+1 ) : ans += ( cmb( b+h-a, i ) % 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...
s834792252
p04046
Runtime Error
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-2,h-1,w-1,a+b-2,a-1,b-1] list2=[] list3=[] import math for i in range(6): list2.append(int(math.factorial(list1[i]))) way1=int(list2[0]/(list2[1]*list2[2])) way2=int(list2[3]/(list2[4]*list2[5])) allways=way1-way2 answer=int(allways%1000000007) print(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...
s436885289
p04046
Runtime Error
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-2,h-1,w-1,a+b-2,a-1,b-1] list2=[] list3=[] import math for i in range(6): list2.append(math.factorial(list[i])) way1=list2[0]/(list2[1]*list2[2]) way2=list2[3]/(list2[4]*list2[5]) allways=way1-way2 answer=int(allways%1000000007) print(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...
s301479046
p04046
Runtime Error
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-1,h,w,a+b-1,a,b] list2=[] list3=[] for i in range(0,4,3): kaijo1=1 kaijo2=1 for j in range (list1[i+1],list1[i]): kaijo1=kaijo1*j for k in range(1,list1[i+2]): kaijo2=kaijo2*k list2.extend([kaijo1,kaijo2]) allways=(list2[0]/list2[1])-(list2[2]/list2[3]) "...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s713811245
p04046
Runtime Error
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-1,h,w,a+b-1,a,b] list2=[] list3=[] for i in range(6): kaijo=1 for j in range(1,list1[i]): kaijo=kaijo*j list2.append(kaijo) for i in range(0,4,3): ways=list2[i]/(list2[i+1]*list2[i+2]) list3.append(ways) allways=list3[0]-list3[1] answer=int(allways%100000000...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s706151819
p04046
Runtime Error
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-1,h,w,a+b-1,a,b] list2=[] list3=[] for i in range(6): kaijo=1 for j in range(1,list1[i]): kaijo=kaijo*j list2.append(kaijo) for i in range(0,4,3): ways=list2[i]/(list2[i+1]*list2[i+2]) list3.append(ways) allways=list3[0]-list3[1] answer=allways%1000000007 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...
s609565863
p04046
Runtime Error
# -*- 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) return int(ans) def C(a,b): #x=np.arange(b+1,a+1) #y=np.arange(1,(a-b)+1) ans = kai(a,(b+1))/kai((a-b),1) 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...
s464500500
p04046
Runtime Error
# -*- coding: utf-8 -*- """ Created on Fri Jul 26 05:23:03 2019 @author: matsui """ def kai(a,b): ans=1 for i in range(a,b-1,-1): ans*=i return ans def C(a,b): return kai(a,(b+1))/kai((a-b),1) H,W,A,B=map(int,input().split()) ans=0 for i in range(H-A): ans+=C((B-1+i),i)*C(((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...
s826989171
p04046
Runtime Error
# -*- coding: utf-8 -*- """ Created on Fri Jul 26 05:23:03 2019 @author: matsui """ def kai(a,b): ans=1 for i in range(a,b-1,-1): ans*=i return ans def C(a,b): return kai(a,(b+1))/kai((a-b),1) H,W,A,B=map(int,input().split()) ans=0 for i in range(H-A): ans+=C((B-1+i),i)*C(((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...
s007796222
p04046
Runtime Error
from operator import mul from functools import reduce 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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s304463816
p04046
Runtime Error
def main(): H, W, A, B = map(int, input().split()) H, W= H-1, W-1 DIV = 10**9+7 size = H+W+1 fact = [0]*size inverse = [0]*size inv_cal = [0]*size fact[:2] = [1, 1] inverse[:2] = [1, 1] inv_cal[:2] = [0, 1] for i in range(2, size): fact[i] = (fact[i-1]*i%DIV) inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%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...
s493540222
p04046
Runtime Error
def main(): H, W, A, B = map(int, input().split()) H, W= H-1, W-1 DIV = 10**9+7 fact = [0]*(H+W-A+1) inverse = [0]*(H+W-A+1) inv_cal = [0]*(H+W-A+1) fact[:2] = [1, 1] inverse[:2] = [1, 1] inv_cal[:2] = [0, 1] for i in range(2, H+W-A+1): fact[i] = (fact[i-1]*i%DIV) inv_cal[i] = (-inv_cal[DIV%i]*(DIV//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...
s078418811
p04046
Runtime Error
[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) 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...
s159977058
p04046
Runtime Error
[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...
s610146808
p04046
Runtime Error
X, Y, Z, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A = sorted(A, key = lambda x:-x) B = sorted(B, key = lambda x:-x) C = sorted(C, key = lambda x:-x) AB = [0] * (X * Y) index = 0 for i in range(len(A)): for j in ra...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s871402893
p04046
Runtime Error
# -*- coding: utf-8 -*- #入力 h,w,a,b=map(int,input().split(" ")) count=0 #階乗の関数を定義 def kaizyou(a): ans=a if a==1 or a==0: ans=1 else: for i in range(1,a): ans=ans*(a-i) return int(ans) for i in range(1,h-a+1): count1=kaizyou(b-1+i-1)/(kaizyou(b-1)*kaizyou(i-1)) count2=...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s121222389
p04046
Runtime Error
# -*- coding: utf-8 -*- import math #入力 h,w,a,b=map(int,input().split(" ")) count=0 for i in range(1,h-a+1): count=count+math.factorial(b-1+i-1)/(math.factorial(b-1)*math.factorial(i-1))*\ math.factorial(w-b-1+h-i)/(math.factorial(int(w-b-1))*math.factorial(h-i)) count=count%(1000000000+7) count=int(count) 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...
s358084306
p04046
Runtime Error
# -*- coding: utf-8 -*- import math #入力 h,w,a,b=map(int,input().split(" ")) count=0 for i in range(1,h-a+1): count=count+math.factorial(b+i-1)/(math.factorial(b)*math.factorial(i-1))*\ math.factorial(w-b-1+h-i)/(math.factorial(w-b-1)*math.factorial(h-i)) count=count%(1000000000+7) count=int(count) print(count)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s051722083
p04046
Runtime Error
def combination(n,r): a,b=1,1 if r==0: return 1 if n-r<int(n/2): r=n-r for i in range(r): a*=n-i b*=i+1 return int(a/b) if __name__=='__main__': H,W,A,B=map(int, input().split()) P=0 for i in range(H-A): if i==H-A-1: P+=combina...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s383555607
p04046
Runtime Error
S = input() #"3 2" W, H = map(int, S.split()) STAGE = [["*" for x in range(W)] for y in range(H)] def set_v(p, v): STAGE[p[1]][p[0]] = v def get_v(p): return STAGE[p[1]][p[0]] def print_stage(): for x in STAGE: print(*x, sep="") def search(cp, c): cx, cy = cp for np in ((cx+1, cy), (cx, cy+1)): nx, ny = np...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s268671799
p04046
Runtime Error
import numpy as np H,W,A,B=map(int,input().split()) memo=np.ones((H,W),int) 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...
s754140731
p04046
Runtime Error
H,W,A,B=map(int,input().split()) def kaijo(a): x=1 for i in range(a): x=x*(i+1) return x def con(a,b): x=kaijo(a) y=kaijo(b) z=kaijo(a-b) res = x/y/z return res 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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s778378142
p04046
Runtime Error
H,W,A,B=map(int,input().split()) def kaijo(a): x=1 for i in range(a): x=x*(i+1) return x def con(a,b): x=kaijo(a) y=kaijo(b) z=kaijo(a-b) res = x/y/z return res 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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s819243823
p04046
Runtime Error
H, W, A, B = map(int, input().split()) answer = 0 mod = 1000000007 factorial = [1] for n in range(1, H+W): factorial.append(factorial[n-1]*n%mod) def power(x, y): if y == 0: return 1 elif y == 1: return x % mod elif y % 2 == 0: return power(x, y/2)**2%mod 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...
s350229894
p04046
Runtime Error
mod = 1000000007 factorial = [1] for n in range(1, H+W): factorial.append(factorial[n-1]*n%mod) def power(x, y): if y == 0: return 1 elif y == 1: return x % mod elif y % 2 == 0: return power(x, y/2)**2%mod else: return power(x, y/2)**2*x%mod inverseFactorial = [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...
s815295226
p04046
Runtime Error
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 # 逆元 inv[N - 1] = pow(fac[N - 1], mod - 2, mod) for i in range(N - 1, 0, -1): inv[i - 1] = (inv[i] * i) % MOD def f(x, y): ans = fac[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...
s696267913
p04046
Runtime Error
import math const MOD = 1000000007 def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n - r)) def main(): H, W, A, B = map(int, input().split()) nr = 0 for i in range(1, N - A + 1): nr = nr + comb(i - 1, B + i - 2) * comb(m - b - 1, m + n - b - i - 1) % MOD 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...
s002687281
p04046
Runtime Error
# -*- coding: utf-8 -*- import math H, W, A, B = map(int, input().split()) union_sum = 0 i = 0 for n in range(B, W): m = H - A - 1 + n tmp_a = math.factorial(m) / (math.factorial(n) * math.factorial(m - n)) tmp_b = math.factorial(A - B + W - 2 - i) / (math.factorial(A - 1) * math.factorial(W - B - 1 - 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...
s457266105
p04046
Runtime Error
# -*- coding: utf-8 -*- import math H, W, A, B = map(int, input().split()) union_sum = 0 i = 0 for n in range(B, W): m = H - A - 1 + n tmp_a = math.factorial(m) / (math.factorial(n) * math.factorial(m - n)) tmp_b = math.factorial(A - B + W - 2 - i) / (math.factorial(A - 1) * math.factorial(W - B - 1 - 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...
s967923296
p04046
Runtime Error
from scipy.special import comb h,w,a,b=map(int,input().split()) s=0 for i in range(1,h-a+1): s=s+comb(i-2+b,i-1,exact=True)*comb(w-b-1+h-i,w-b-1,exact=True) print(s%(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...
s811046672
p04046
Runtime Error
H, W, A, B = (int(i) for i in input().split()) #H, W, A, B = (10, 7, 3, 4) #H, W, A, B = (2, 3, 1, 1) def mycomb(n, k): return factorials[n] / (factorials[k] * factorials[n - k]) MOD = int(1e9 + 7) factorials = [] factorials.append(1) for i in range(1, W + H): factorials.append(factorials[i - 1] * i) r = 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...
s406867392
p04046
Runtime Error
H, W, A, B = (int(i) for i in input().split()) #H, W, A, B = (10, 7, 3, 4) #H, W, A, B = (2, 3, 1, 1) def mycomb(n, k): return factorials[n] / (factorials[k] * factorials[n - k]) MOD = int(1e9 + 7) factorials = [] factorials.append(1) for i in range(1, W + H): factorials.append(factorials[i - 1] * i) r = 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...
s869620922
p04046
Runtime Error
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 w-j <= b: 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...
s904718383
p04046
Runtime Error
isPrime = [True for i in range(100001)] isPrime[0] = False isPrime[1] = False for i in range(2, 100001): if isPrime[i]: j = 2 while i*j <= 100000: isPrime[i*j] = False j += 1 q = int(input()) que = list() for i in range(q): que.append(list(map(int, input().split()))) 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...
s478565665
p04046
Runtime Error
import numpy as np from math import factorial H, W, A, B = map(int, input().split(' ')) def nCmRemain(n, m): return ((factorial(n)/factorial(n - m))/factorial(m)) % (pow(10,9)+7) path = np.zeros((A+1, W-B), dtype=np.int) for i in range(W-B): path[0][i] = nCmRemain(H-A+B-1+i,B+i) for i in range(A+1): path[...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s585833246
p04046
Runtime Error
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]//%pfact[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...