node_ids listlengths 4 1.4k | edge_index listlengths 1 2.22k | text listlengths 4 1.4k | source stringlengths 14 427k |
|---|---|---|---|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
41,
28,
13,
4,
13,
2,
2,
13,
13,
17,
4,
17,
0,
13,
13,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
0,
18,
13,
13,
2,
2,
18,
13,
... | [
[
161,
4
],
[
161,
13
],
[
161,
14
],
[
161,
15
],
[
137,
17
],
[
26,
25
],
[
141,
30
],
[
153,
31
],
[
149,
36
],
[
40,
39
],
[
141,
45
],
[
153,
46
],
[
52,
49
... | [
"import math\nH, W, A, B = map(int, input().split())\np = 10 ** 9 + 7\nF = [1 for i in range(H + W + 1)]\nfor i in range(1, H + W + 1):\n F[i] = F[i - 1] * i % p\ndef fac(a, b):\n a = F[a + b] * pow(F[a], p - 2, p) * pow(F[b], p - 2, p)\n return a % p\nans = 0\nfor h in range(H - A):\n ans += fac(h, B - 1) * fa... | import math
H, W, A, B = map(int, input().split())
p = 10 ** 9 + 7
F = [1 for i in range(H + W + 1)]
for i in range(1, H + W + 1):
F[i] = F[i - 1] * i % p
def fac(a, b):
a = F[a + b] * pow(F[a], p - 2, p) * pow(F[b], p - 2, p)
return a % p
ans = 0
for h in range(H - A):
ans += fac(h, B - 1) * fac(H - h - 1, W -... |
[
7,
15,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
2,
39,
13,
13,
12,
13,
23,
13,
23,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
13,
12,
13,
23,
13,
23,
13,
23,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
13,
12,
13,
23,
13,
... | [
[
8,
7
],
[
19,
19
],
[
21,
21
],
[
23,
23
],
[
27,
26
],
[
35,
35
],
[
37,
37
],
[
39,
39
],
[
41,
41
],
[
45,
44
],
[
53,
53
],
[
55,
55
],
[
57,
57
],
[
... | [
"# -*- coding: utf-8 -*-\n\nimport sys\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for ... | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a... |
[
7,
6,
13,
12,
13,
0,
18,
13,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
13,
2,
39,
17,
2,
13,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
13,
13,
13,
0,
13,
2,
18,
13,
13,
17,
28,
13,
4,
13,
... | [
[
9,
6
],
[
105,
7
],
[
107,
13
],
[
19,
16
],
[
105,
17
],
[
107,
23
],
[
31,
26
],
[
6,
27
],
[
105,
28
],
[
38,
33
],
[
16,
34
],
[
105,
35
],
[
43,
40
],
[
... | [
"class Factorial:\n def __init__(self, n, mod=10**9+7):\n self.fac = [0] * (n+1)\n self.ifac = [0] * (n+1)\n self.fac[0] = 1\n self.ifac[0] = 1\n self.mod = mod\n modmod = self.mod - 2\n for i in range(n):\n self.fac[i+1] = self.fac[i] * (i+1) % self.mo... | class Factorial:
def __init__(self, n, mod=10**9+7):
self.fac = [0] * (n+1)
self.ifac = [0] * (n+1)
self.fac[0] = 1
self.ifac[0] = 1
self.mod = mod
modmod = self.mod - 2
for i in range(n):
self.fac[i+1] = self.fac[i] * (i+1) % self.mod
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
39,
17,
17,
0,
13,
2,
39,
17,
17,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
17,
17,
0,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
17,
0,
18,
13,... | [
[
232,
2
],
[
232,
11
],
[
232,
12
],
[
232,
13
],
[
208,
15
],
[
214,
21
],
[
30,
27
],
[
209,
28
],
[
220,
32
],
[
36,
35
],
[
44,
41
],
[
209,
42
],
[
35,
43
]... | [
"h,w,a,b=map(int,input().split())\nfac=[0]*200001#iの階乗mod(1000000007)\ninv=[0]*200001#iの逆元mod(1000000007)\nfac[0]=1\nans=0\nfor i in range(1,200001):\n fac[i]=fac[i-1]*i%1000000007\ninv[200000]=pow(fac[200000],1000000005,1000000007)\nfor i in range(199999,0,-1):\n inv[i]=(inv[i+1]*(i+1))%1000000007\n inv[0... | h,w,a,b=map(int,input().split())
fac=[0]*200001#iの階乗mod(1000000007)
inv=[0]*200001#iの逆元mod(1000000007)
fac[0]=1
ans=0
for i in range(1,200001):
fac[i]=fac[i-1]*i%1000000007
inv[200000]=pow(fac[200000],1000000005,1000000007)
for i in range(199999,0,-1):
inv[i]=(inv[i+1]*(i+1))%1000000007
inv[0]=1
for i in ra... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
13,
4,
18,
13,
13,
4,
13,
... | [
[
178,
2
],
[
178,
11
],
[
178,
12
],
[
178,
13
],
[
169,
15
],
[
163,
22
],
[
151,
26
],
[
31,
30
],
[
167,
36
],
[
149,
37
],
[
164,
41
],
[
164,
46
],
[
30,
48
... | [
"H, W, A, B = map(int, input().split())\nMOD = 10 ** 9 + 7\n\n# 階乗 & 逆元計算\nfactorial = [1]\ninverse = [1]\nfor i in range(1, H + W + 2):\n factorial.append(factorial[-1] * i % MOD)\n inverse.append(pow(factorial[-1], MOD - 2, MOD))\n\n\n# 組み合わせ計算\ndef nCr(n, r):\n if n < r or r < 0:\n return 0\n ... | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, H + W + 2):
factorial.append(factorial[-1] * i % MOD)
inverse.append(pow(factorial[-1], MOD - 2, MOD))
# 組み合わせ計算
def nCr(n, r):
if n < r or r < 0:
return 0
elif r == 0:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
4,
13,
2,
17,
17,
0,
13,
2,
13,
17,
0,
13,
2,
13,
13,
13,
2,
13,
13,
0,
13,
39,
42,
40,
13,
17,
0,
13,
2,
39,
2,
13,
17,
18,
13,
39,
0,
13,
17,
0,
... | [
[
326,
2
],
[
326,
11
],
[
326,
12
],
[
326,
13
],
[
332,
15
],
[
272,
22
],
[
333,
24
],
[
284,
27
],
[
261,
29
],
[
258,
30
],
[
317,
31
],
[
327,
33
],
[
264,
34... | [
"H, W, A, B = map(int, input().split())\nmod = int(1e+9 + 7)\np = mod - 2\nX, Y = H-A, W-B\nL = []\nwhile p != 0:\n L = [p%2] + L[:]\n p //= 2\nS = 0\nfL = [1]\ninvfL = []\nfor i in range(H+W):\n fL.append(((i+1)*fL[i])%mod)\nfor i in range(H):\n invi = 1\n for j in range(len(L)):\n if L[j] == 1:\n inv... | H, W, A, B = map(int, input().split())
mod = int(1e+9 + 7)
p = mod - 2
X, Y = H-A, W-B
L = []
while p != 0:
L = [p%2] + L[:]
p //= 2
S = 0
fL = [1]
invfL = []
for i in range(H+W):
fL.append(((i+1)*fL[i])%mod)
for i in range(H):
invi = 1
for j in range(len(L)):
if L[j] == 1:
invi *= fL[i]
invi ... |
[
7,
15,
13,
15,
13,
15,
15,
13,
15,
0,
13,
18,
13,
13,
4,
13,
2,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
2,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39... | [
[
224,
10
],
[
23,
22
],
[
225,
29
],
[
23,
31
],
[
23,
32
],
[
23,
33
],
[
36,
35
],
[
43,
42
],
[
50,
49
],
[
55,
54
],
[
60,
59
],
[
102,
68
],
[
102,
71
],
... | [
"import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n h,w,a,b = map(int,ip... | import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
h,w,a,b = map(int,ipt().split())
... |
[
7,
15,
13,
0,
13,
2,
4,
13,
17,
17,
17,
4,
18,
13,
13,
4,
13,
17,
17,
12,
13,
14,
2,
13,
17,
14,
2,
13,
17,
14,
2,
2,
13,
17,
17,
23,
13,
23,
13,
12,
13,
29,
2,
2,
2,
13,
13,
2,
13,
13,
13,
23,
13,
23,
13,
... | [
[
343,
4
],
[
38,
23
],
[
38,
27
],
[
38,
32
],
[
36,
36
],
[
38,
38
],
[
52,
45
],
[
344,
46
],
[
54,
48
],
[
344,
49
],
[
344,
50
],
[
52,
52
],
[
54,
54
],
[... | [
"import sys\nmod = pow(10, 9) + 7\nsys.setrecursionlimit(pow(10, 8))\n\ndef power(x, y):\n if y == 0: return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y//2)**2 % mod\n else: return power(x, (y-1)//2)**2 * x % mod\n \ndef mul(a, b):\n return ((a % mod) * (b % mod)) ... | 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... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17,
13,
2,
39,
17,
2,
2,
13,
13,
17,
12,
13,
29,
4,
13,
13,
2,
13,
17,
13,
23,
13,
0,
18,
13,
17,
... | [
[
165,
2
],
[
195,
9
],
[
195,
18
],
[
195,
19
],
[
195,
20
],
[
189,
22
],
[
193,
28
],
[
196,
29
],
[
177,
31
],
[
193,
37
],
[
196,
38
],
[
51,
45
],
[
166,
47
... | [
"mod=10**9+7\nh,w,a,b=map(int,input().split())\nF,I=[0]*(h+w+2),[0]*(h+w+2)\ndef inv(n):\n return pow(n,mod-2,mod)\nF[0],F[1],I[0],I[1]=1,1,1,1\nfor i in range(2,h+w+2):\n F[i]=i*F[i-1]%mod\n I[i]=inv(F[i])\ndef c(a,b):\n return F[a+b]*I[a]*I[b]%mod\nans=0\nfor i in range(b+1,w+1):\n ans+=(c(h-a-1,i-1)*c(a-1,w... | mod=10**9+7
h,w,a,b=map(int,input().split())
F,I=[0]*(h+w+2),[0]*(h+w+2)
def inv(n):
return pow(n,mod-2,mod)
F[0],F[1],I[0],I[1]=1,1,1,1
for i in range(2,h+w+2):
F[i]=i*F[i-1]%mod
I[i]=inv(F[i])
def c(a,b):
return F[a+b]*I[a]*I[b]%mod
ans=0
for i in range(b+1,w+1):
ans+=(c(h-a-1,i-1)*c(a-1,w-i))%mod
print(ans... |
[
7,
15,
15,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
2,
2,
17,
17,
17,
4,
13,
0,
13,
17,
12,
13,
29,
2,
2,
2,
18,
13,
2,
13,
13,
18,
13,
13,
18,
13,
13,
13,
23,
13,
23,
13,
0,
13... | [
[
196,
5
],
[
196,
14
],
[
196,
15
],
[
196,
16
],
[
190,
18
],
[
175,
21
],
[
31,
30
],
[
51,
41
],
[
53,
42
],
[
51,
45
],
[
53,
48
],
[
176,
49
],
[
51,
51
],
... | [
"from operator import mul\nfrom functools import reduce\nfrom functools import lru_cache\n\n\nH,W,A,B = map(int,input().split())\nans = 0\nmod = 10**9+7\n\nlru_cache(maxsize=None)\ndef cmb(c, r):\n return fc[c + r] * ic[c] * ic[r] % mod\n \nfc = [1] * (H + W)\nfor i in range(2, H+W):\n fc[i] = fc[i - 1] * i %... | from operator import mul
from functools import reduce
from functools import lru_cache
H,W,A,B = map(int,input().split())
ans = 0
mod = 10**9+7
lru_cache(maxsize=None)
def cmb(c, r):
return fc[c + r] * ic[c] * ic[r] % mod
fc = [1] * (H + W)
for i in range(2, H+W):
fc[i] = fc[i - 1] * i % mod
ic = [pow(x, mo... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
17,
0,
13,
2,
2,
2,
2,
13,
13,
17,
13,
17,
0,
13,
2,
13,
17,
0,
13,
17,
0,
13,
39,
17,
0,
13,
17,
28,
13,
4,
13,
... | [
[
213,
3
],
[
213,
12
],
[
213,
13
],
[
213,
14
],
[
159,
16
],
[
198,
19
],
[
178,
21
],
[
186,
24
],
[
216,
27
],
[
181,
32
],
[
178,
33
],
[
214,
35
],
[
168,
38... | [
"from math import comb\nh,w,a,b = map(int,input().split())\ns = 0\nnC = b-1\nkC = 0\nnD = w-b-1+h-1\nkD = h-1\np = 1000000007\nfac = [1]\nff = 1\nfor i in range(1,200001):\n ff *= i\n ff %= p\n fac.append(ff)\ndef ncr(n, r, p): \n return (fac[n] * pow(fac[r], p-2, p) % p * pow(fac[n-r], p-2, p) % p);\n\nfor i i... | from math import comb
h,w,a,b = map(int,input().split())
s = 0
nC = b-1
kC = 0
nD = w-b-1+h-1
kD = h-1
p = 1000000007
fac = [1]
ff = 1
for i in range(1,200001):
ff *= i
ff %= p
fac.append(ff)
def ncr(n, r, p):
return (fac[n] * pow(fac[r], p-2, p) % p * pow(fac[n-r], p-2, p) % p);
for i in range(h-a):
C = nc... |
[
7,
12,
13,
29,
4,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
13,
13,
17,
0,
13,
39,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
12,
13,
14,
2,
13,
17,
29,
17,
0,
13,
4,
13,
13,... | [
[
271,
29
],
[
274,
33
],
[
262,
40
],
[
83,
47
],
[
53,
52
],
[
81,
55
],
[
83,
57
],
[
61,
60
],
[
52,
63
],
[
52,
64
],
[
275,
65
],
[
83,
69
],
[
60,
73
],
... | [
"\n\ndef read_int():\n return int(input().strip())\n\n\ndef read_ints():\n return list(map(int, input().strip().split(' ')))\n\n\nfactorial = [1]\nmodulo = 10**9+7\ninverse_factorial = [0]\n\n\ndef pow1(a, p):\n if p == 0:\n return 1\n half = pow1(a, p//2)\n total = (half*half)%modulo\n if ... |
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
factorial = [1]
modulo = 10**9+7
inverse_factorial = [0]
def pow1(a, p):
if p == 0:
return 1
half = pow1(a, p//2)
total = (half*half)%modulo
if p%2 == 0:
return ... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
13,
0,... | [
[
218,
4
],
[
218,
20
],
[
218,
21
],
[
218,
22
],
[
224,
24
],
[
203,
31
],
[
36,
35
],
[
195,
41
],
[
198,
42
],
[
204,
46
],
[
204,
51
],
[
35,
53
],
[
225,
54
... | [
"import sys\nH,W,A,B = map(int,sys.stdin.readline().rstrip().split())\nmod = 10**9+7\n\nkaijou = [1]\nfor i in range(1,H+W-1):\n kaijou.append((kaijou[-1]*i) % mod)\n\na = 0\nfor i in range(B):\n b = kaijou[(H-A-1)+i]*pow(kaijou[i],mod-2,mod)*pow(kaijou[H-A-1],mod-2,mod)\n b %= mod\n b *= kaijou[(W+A-2)... | import sys
H,W,A,B = map(int,sys.stdin.readline().rstrip().split())
mod = 10**9+7
kaijou = [1]
for i in range(1,H+W-1):
kaijou.append((kaijou[-1]*i) % mod)
a = 0
for i in range(B):
b = kaijou[(H-A-1)+i]*pow(kaijou[i],mod-2,mod)*pow(kaijou[H-A-1],mod-2,mod)
b %= mod
b *= kaijou[(W+A-2)-i]*pow(kaijou[A-... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
12,
13,
14,
2,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
29,
2,
2,
2,
2,
18,
13,
13,
18,
13,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,... | [
[
164,
2
],
[
185,
9
],
[
185,
18
],
[
185,
19
],
[
185,
20
],
[
54,
25
],
[
56,
26
],
[
54,
30
],
[
56,
33
],
[
54,
42
],
[
56,
45
],
[
165,
46
],
[
54,
50
],
... | [
"mod = 10 ** 9 + 7\nh, w, a, b = map(int, input().split())\ndef comb(n, r):\n if n < r:return 0\n if n < 0 or r < 0:return 0\n return fa[n] * fi[r] % mod * fi[n - r] % mod\nfa = [1] * (h + w + 1)\nfi = [1] * (h + w + 1)\nfor i in range(1, h + w + 1):\n fa[i] = fa[i - 1] * i % mod\n fi[i] = pow(fa[i],... | mod = 10 ** 9 + 7
h, w, a, b = map(int, input().split())
def comb(n, r):
if n < r:return 0
if n < 0 or r < 0:return 0
return fa[n] * fi[r] % mod * fi[n - r] % mod
fa = [1] * (h + w + 1)
fi = [1] * (h + w + 1)
for i in range(1, h + w + 1):
fa[i] = fa[i - 1] * i % mod
fi[i] = pow(fa[i], mod - 2, mod)
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
39,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
2,
2,
13,
2,
13,
17,
13,
4,
18,
13,
13,
13,
29,
13,
23,
13,
12,
13,
0,... | [
[
233,
2
],
[
233,
11
],
[
233,
12
],
[
233,
13
],
[
194,
15
],
[
25,
24
],
[
29,
28
],
[
32,
31
],
[
52,
34
],
[
37,
36
],
[
28,
39
],
[
36,
39
],
[
31,
41
],
... | [
"H, W, A, B = map(int, input().split())\n\nMOD = 10 ** 9 + 7\n\n\ndef get_fact_list(n: int) -> list:\n result_list = [1]\n tmp = 1\n for i in range(n):\n tmp = (tmp * (i + 1)) % MOD\n result_list.append(tmp)\n\n return result_list\n\n\ndef get_inv_list(n: int, fact_lit: list) -> list:\n ... | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
def get_fact_list(n: int) -> list:
result_list = [1]
tmp = 1
for i in range(n):
tmp = (tmp * (i + 1)) % MOD
result_list.append(tmp)
return result_list
def get_inv_list(n: int, fact_lit: list) -> list:
result_list = [1]
... |
[
7,
12,
13,
29,
2,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
29,
2,
2,
13,
4,
13,
13,
2,
13,
17,
13,
23,
13,
23,
13,
23,
13,
12,
13,
29,
4,
13,
13,
2,
13,
17,
23,
13,
23,
13,
12,
13,
0,
13,
17,
0,
13,
39,... | [
[
10,
6
],
[
12,
7
],
[
14,
8
],
[
10,
10
],
[
12,
12
],
[
14,
14
],
[
29,
20
],
[
31,
23
],
[
33,
25
],
[
33,
27
],
[
29,
29
],
[
31,
31
],
[
33,
33
],
[
4... | [
"\n#modの掛け算\n \ndef modmal(a,b,mod): #a*bをmodを法にして求める\n \n return a * b % mod\n \n \n#modの割り算\n \ndef moddiv(a,b,mod): #a/bをmodを法にして求める\n \n return (a * pow(b,mod-2)) % mod\n \n \n#逆元\n \ndef inverse(a,mod): #aのmodを法にした逆元を返す\n return pow(a,mod-2)\n \n \n \n#modのn!と、n!の逆元を格納したリストを返す(拾いもの)\n#factorialsには[1, ... |
#modの掛け算
def modmal(a,b,mod): #a*bをmodを法にして求める
return a * b % mod
#modの割り算
def moddiv(a,b,mod): #a/bをmodを法にして求める
return (a * pow(b,mod-2)) % mod
#逆元
def inverse(a,mod): #aのmodを法にした逆元を返す
return pow(a,mod-2)
#modのn!と、n!の逆元を格納したリストを返す(拾いもの)
#factorialsには[1, 1!%mod , 2!%mod , 6!%mod… , ... |
[
7,
12,
13,
14,
2,
13,
17,
29,
39,
17,
17,
13,
0,
13,
4,
13,
13,
2,
13,
13,
13,
13,
0,
13,
2,
2,
13,
13,
13,
29,
39,
13,
13,
13,
23,
13,
23,
13,
12,
13,
0,
13,
4,
13,
13,
13,
13,
13,
29,
2,
13,
13,
23,
13,
23,... | [
[
37,
5
],
[
14,
13
],
[
37,
16
],
[
35,
18
],
[
37,
19
],
[
14,
20
],
[
14,
21
],
[
24,
23
],
[
35,
26
],
[
37,
27
],
[
20,
28
],
[
35,
35
],
[
37,
37
],
[
... | [
"def ext_euclid(a, b):\n # return (x, y, gcd(a, b)) such that a * x + b * y = gcd(a, b)\n if b == 0:\n return 1, 0, a\n y, x, v = ext_euclid(b, a % b)\n y -= (a // b) * x\n return x, y, v\n\n\ndef mod_inv(a, mod):\n x, _, _ = ext_euclid(a, mod)\n return x % mod\n\n\ndef comb_list_1(H, W,... | def ext_euclid(a, b):
# return (x, y, gcd(a, b)) such that a * x + b * y = gcd(a, b)
if b == 0:
return 1, 0, a
y, x, v = ext_euclid(b, a % b)
y -= (a // b) * x
return x, y, v
def mod_inv(a, mod):
x, _, _ = ext_euclid(a, mod)
return x % mod
def comb_list_1(H, W, A, B, mod, modinv_... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
13,
0,
13,
39,
4,
13,
18,
13,
17,
2,
... | [
[
186,
3
],
[
186,
12
],
[
186,
13
],
[
186,
14
],
[
159,
16
],
[
168,
23
],
[
28,
27
],
[
187,
33
],
[
181,
34
],
[
169,
38
],
[
169,
43
],
[
27,
45
],
[
160,
46
... | [
"from math import factorial\n\nh, w, a, b = map(int, input().split())\nMOD = 10**9+7\n\nfact = [1]\n\n# 累積乗を作る\nfor i in range(1, h+w-1):\n fact.append(fact[-1] * i % MOD)\n\n# 累積乗の逆元\ninv_fact = [pow(fact[-1], MOD-2, MOD)] # x^(-1) = x^(10^9+5) % (10^9+7), フェルマーの小定理\nfor i in range(h+w-2, 0, -1): # xが最大の場合を求め、後... | 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... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
12,
13,
29,
4,
13,
13,
2,
13,
17,
13,
23,
13,
12,
13,
29,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
23,
13,
23,
13,
0,
13,
... | [
[
225,
2
],
[
228,
9
],
[
228,
18
],
[
228,
19
],
[
228,
20
],
[
32,
26
],
[
226,
28
],
[
226,
30
],
[
32,
32
],
[
50,
40
],
[
52,
43
],
[
50,
47
],
[
52,
48
],
... | [
"MOD=10**9+7\nH,W,A,B=map(int,input().split())\n\ndef invmod(a):\n return pow(a,MOD-2,MOD)\ndef comb_mod(n,r):\n return fact_dic[n]*fact_inv_dic[r]*fact_inv_dic[n-r]\n\nfact_dic={0:1}\nfact_inv_dic={0:1}\nfact_mod=1\nfor i in range(1,H+W-1):\n fact_mod=(fact_mod*i)%MOD\n fact_dic[i]=fact_mod\n fact_inv_dic[i]=... | MOD=10**9+7
H,W,A,B=map(int,input().split())
def invmod(a):
return pow(a,MOD-2,MOD)
def comb_mod(n,r):
return fact_dic[n]*fact_inv_dic[r]*fact_inv_dic[n-r]
fact_dic={0:1}
fact_inv_dic={0:1}
fact_mod=1
for i in range(1,H+W-1):
fact_mod=(fact_mod*i)%MOD
fact_dic[i]=fact_mod
fact_inv_dic[i]=invmod(fact_mod)
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
1... | [
[
224,
2
],
[
224,
11
],
[
224,
12
],
[
224,
13
],
[
53,
19
],
[
53,
22
],
[
51,
23
],
[
28,
27
],
[
53,
30
],
[
51,
32
],
[
53,
33
],
[
51,
40
],
[
27,
43
],
[... | [
"h,w,a,b=map(int,input().split())\n#コンビネーション逆元\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\nmod = 10**9+7 #出力の制限\nN = 10**6\ng1 = [1, 1] # 元テーブル\ng2 = [1, 1] #逆元テーブル\ninverse = [0, 1] #逆元テーブル計算用テーブル\n\n\nfor i in range( 2, N + 1 )... | h,w,a,b=map(int,input().split())
#コンビネーション逆元
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1... |
[
7,
15,
15,
15,
15,
13,
15,
13,
15,
13,
41,
28,
13,
4,
18,
4,
18,
18,
18,
13,
13,
13,
13,
13,
4,
4,
13,
13,
12,
13,
12,
13,
41,
28,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
4,
13,
13,
12,
13,
12,
13,
0,
13,
4,... | [
[
13,
12
],
[
12,
27
],
[
35,
34
],
[
34,
47
],
[
54,
53
],
[
53,
65
],
[
53,
70
],
[
53,
74
],
[
80,
79
],
[
89,
82
],
[
331,
85
],
[
89,
89
],
[
95,
94
],
[
... | [
"#!usr/bin/env python3\nfrom collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom itertools import permutations, accumulate\nimport sys\nimport math\nimport bisect\ndef LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]\ndef I(): return int(sys.stdin.buffer.readline())\nd... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return... |
[
7,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
1... | [
[
32,
6
],
[
30,
9
],
[
32,
10
],
[
30,
19
],
[
32,
22
],
[
30,
26
],
[
32,
27
],
[
34,
28
],
[
30,
30
],
[
32,
32
],
[
34,
34
],
[
172,
36
],
[
178,
43
],
[
... | [
"def combmod(n, r, p):\n if r < 0 or n < r:\n return 0\n return fact[n] * finv[r] * finv[n-r] % p\n\n\np = 10**9+7\nN = 10**6\nfact = [1, 1]\nfinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N+1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n finv.append((finv[... | def combmod(n, r, p):
if r < 0 or n < r:
return 0
return fact[n] * finv[r] * finv[n-r] % p
p = 10**9+7
N = 10**6
fact = [1, 1]
finv = [1, 1]
inv = [0, 1]
for i in range(2, N+1):
fact.append((fact[-1] * i) % p)
inv.append((-inv[p % i] * (p // i)) % p)
finv.append((finv[-1] * inv[-1]) % p)
... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
2,
17,
17,
0,
13,
2,
39,
17,
17,
2,
39,
17,
13,
0,
13,
2,
39,
17,
17,
2,
39,
17,
13,
0,
13,
2,
39,
17,
17,
2,
39,
17,
13,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
... | [
[
226,
2
],
[
208,
9
],
[
220,
16
],
[
209,
24
],
[
217,
26
],
[
209,
34
],
[
202,
36
],
[
209,
44
],
[
47,
46
],
[
209,
51
],
[
57,
54
],
[
221,
55
],
[
46,
56
]... | [
"# Combination\nMOD = 10**9+7\nMAX = 2*10**5\nfac = [1,1] + [0]*MAX\nfinv = [1,1] + [0]*MAX\ninv = [0,1] + [0]*MAX\nfor i in range(2,MAX+2):\n fac[i] = fac[i-1] * i % MOD\n inv[i] = -inv[MOD%i] * (MOD // i) % MOD\n finv[i] = finv[i-1] * inv[i] % MOD\n\ndef comb(n,r):\n if n < r: return 0\n if n < 0 o... | # Combination
MOD = 10**9+7
MAX = 2*10**5
fac = [1,1] + [0]*MAX
finv = [1,1] + [0]*MAX
inv = [0,1] + [0]*MAX
for i in range(2,MAX+2):
fac[i] = fac[i-1] * i % MOD
inv[i] = -inv[MOD%i] * (MOD // i) % MOD
finv[i] = finv[i-1] * inv[i] % MOD
def comb(n,r):
if n < r: return 0
if n < 0 or r < 0: return 0
... |
[
7,
15,
13,
15,
13,
15,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
39,
17,
17,
39,
17,
17,
39,
17,
17,
39,
17,
17,
12,
13,
41,
28,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
4,
13,
13,
12,
13,
12,
13,
41,
28,
13,
4... | [
[
421,
8
],
[
448,
15
],
[
34,
33
],
[
33,
46
],
[
54,
53
],
[
437,
59
],
[
63,
63
],
[
82,
68
],
[
73,
68
],
[
72,
71
],
[
82,
72
],
[
73,
72
],
[
74,
73
],
[
... | [
"import sys\nimport heapq\nimport bisect\n\nmod = 10**9+7\ndd = ((-1,0),(1,0),(0,-1),(0,1))\n\ndef I(): return(int(sys.stdin.readline()))\ndef LI(): return([int(x) for x in sys.stdin.readline().split()])\ndef S(): return(sys.stdin.readline()[:-1])\ndef IR(n): return([I() for _ in range(n)])\n\ndef GCD(a,b):\n wh... | import sys
import heapq
import bisect
mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))
def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])
def GCD(a,b):
while b!=0:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
13,
0,
13,
39,
4,
13,
18,
13,
... | [
[
173,
2
],
[
173,
11
],
[
173,
12
],
[
173,
13
],
[
164,
15
],
[
150,
17
],
[
171,
18
],
[
182,
20
],
[
152,
27
],
[
32,
31
],
[
165,
36
],
[
153,
40
],
[
153,
45
... | [
"H,W,A,B=map(int,input().split())\nN=H+W\nmod=10**9+7\nfactl=[1]\nfor i in range(1,N+1):\n factl.append(factl[-1]*i%mod)\ninvl=[pow(factl[-1],mod-2,mod)]\nfor i in range(N,0,-1):\n invl.append(invl[-1]*i%mod)\ninvl.reverse()\ndef Comb(a,b):\n return factl[a]*invl[a-b]*invl[b]\nans=0\nfor i in range(H-A):\n... | H,W,A,B=map(int,input().split())
N=H+W
mod=10**9+7
factl=[1]
for i in range(1,N+1):
factl.append(factl[-1]*i%mod)
invl=[pow(factl[-1],mod-2,mod)]
for i in range(N,0,-1):
invl.append(invl[-1]*i%mod)
invl.reverse()
def Comb(a,b):
return factl[a]*invl[a-b]*invl[b]
ans=0
for i in range(H-A):
ans+=Comb(B+i-1... |
[
7,
12,
13,
29,
2,
2,
18,
13,
13,
18,
13,
2,
13,
13,
18,
13,
13,
23,
13,
23,
13,
12,
13,
41,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17... | [
[
18,
8
],
[
18,
12
],
[
20,
13
],
[
20,
16
],
[
18,
18
],
[
20,
20
],
[
26,
25
],
[
26,
36
],
[
26,
37
],
[
26,
38
],
[
41,
40
],
[
48,
47
],
[
25,
53
],
[
... | [
"# ABC042D - いろはちゃんとマス目 / Iroha and a Grid (ARC058D)\ndef comb(n: int, r: int) -> int:\n return fact[n] * inv[n - r] * inv[r]\n\n\ndef main():\n global fact, inv\n H, W, A, B = tuple(map(int, input().split()))\n MOD = 10 ** 9 + 7\n # table of factorials\n fact, x = [1] * (H + W + 1), 1\n for i ... | # ABC042D - いろはちゃんとマス目 / Iroha and a Grid (ARC058D)
def comb(n: int, r: int) -> int:
return fact[n] * inv[n - r] * inv[r]
def main():
global fact, inv
H, W, A, B = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7
# table of factorials
fact, x = [1] * (H + W + 1), 1
for i in range(1, H + ... |
[
7,
15,
15,
13,
4,
18,
13,
13,
2,
17,
17,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
0,
13,
12,
2,
4,
13,
13,
17,
23,
12,
13,
12,
13,
0,
13,
12,
4,
13,
31,
13,... | [
[
25,
24
],
[
435,
30
],
[
34,
34
],
[
413,
36
],
[
407,
49
],
[
57,
56
],
[
437,
60
],
[
82,
79
],
[
86,
80
],
[
88,
83
],
[
86,
86
],
[
88,
88
],
[
98,
95
],
... | [
"from itertools import permutations\nimport sys\n\nsys.setrecursionlimit(10 ** 6)\nfrom bisect import *\nfrom collections import *\nfrom heapq import *\n\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split())... | from itertools import permutations
import sys
sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): ret... |
[
7,
15,
13,
41,
28,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
13,
13,
0,
13,
4,
13,
0,
13,
2,
2,
17,
17,
17,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,... | [
[
6,
5
],
[
5,
18
],
[
257,
20
],
[
257,
22
],
[
257,
23
],
[
257,
24
],
[
227,
26
],
[
215,
30
],
[
75,
41
],
[
75,
44
],
[
73,
45
],
[
50,
49
],
[
75,
52
],
[... | [
"import sys\nh, w, a, b = [int(i) for i in sys.stdin.readline().split()]\ndic = dict()\nMOD = 10**9+7\n\ndef nCr(n, r, mod=MOD):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 #出力の制限\nN = 10**6\ng1 = [1, 1] # 元テーブル\ng2 = [1, 1] #逆元テーブル\ninve... | import sys
h, w, a, b = [int(i) for i in sys.stdin.readline().split()]
dic = dict()
MOD = 10**9+7
def nCr(n, r, mod=MOD):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
2,
13,
13,
17,
0,
13,
2,
39,
17,
13,
13,
2,
39,
17,
13,
28,
13,
4,
13,
17,
13,
0,
18,
13,
13,
2,
2,
13,
18,
13,
2,
13,
... | [
[
182,
2
],
[
182,
11
],
[
182,
12
],
[
182,
13
],
[
155,
15
],
[
164,
22
],
[
183,
25
],
[
171,
26
],
[
179,
29
],
[
165,
33
],
[
176,
34
],
[
165,
38
],
[
41,
40
... | [
"h,w,a,b=map(int,input().split())\nmod=10**9+7\n\nn=h+w+1\nfc,inv=[1]*n,[1]*n\nfor i in range(1,n):\n fc[i]=i*fc[i-1]%mod\ninv[n-1]=pow(fc[n-1],mod-2,mod)\nfor i in range(n-1,0,-1):\n inv[i-1]=inv[i]*i%mod\nf=lambda a,b:fc[a+b]*inv[a]*inv[b]%mod\n\nv=0\nfor i in range(b,w):\n v+=f(h-a-1,i)*f(a-1,w-i-1)%mod... | 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%mod)
|
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
13,
12,
13,
29,
2,
2,
2,
18,
13,
13,
4,
13,
... | [
[
166,
2
],
[
172,
9
],
[
160,
12
],
[
173,
17
],
[
23,
20
],
[
161,
21
],
[
26,
25
],
[
173,
30
],
[
36,
33
],
[
161,
34
],
[
25,
35
],
[
161,
39
],
[
25,
41
],
... | [
"mod = 10**9 + 7\nN = 200000\nfact = [None] * (N+1)\nfact[0] = 1\nfor i in range(1, N+1):\n fact[i] = fact[i-1] * i % mod\n\ndef comb(n, k):\n return fact[n] * pow(fact[k], mod-2, mod) * pow(fact[n-k], mod-2, mod) % mod\n\nH, W, A, B = map(int, input().split())\nans = 0\nfor b in range(B+1, W+1):\n tmp = c... | mod = 10**9 + 7
N = 200000
fact = [None] * (N+1)
fact[0] = 1
for i in range(1, N+1):
fact[i] = fact[i-1] * i % mod
def comb(n, k):
return fact[n] * pow(fact[k], mod-2, mod) * pow(fact[n-k], mod-2, mod) % mod
H, W, A, B = map(int, input().split())
ans = 0
for b in range(B+1, W+1):
tmp = comb(H-A+b-2, b-1) ... |
[
7,
12,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
17,
29,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
13,
0,
13,
13,
29,
13,
23,
13,
23,
13,
0,
13,
... | [
[
5,
4
],
[
8,
7
],
[
25,
10
],
[
13,
12
],
[
23,
13
],
[
18,
13
],
[
16,
15
],
[
27,
16
],
[
19,
18
],
[
15,
21
],
[
12,
21
],
[
4,
21
],
[
23,
23
],
[
25,... | [
"def permutation(n, k, mod):\n s = 1\n for _ in range(k):\n s *= n\n s %= mod\n n -= 1\n return s\n\ndef factorial(n, mod):\n s = 1\n for i in range(1, n + 1):\n s *= i\n s %= mod\n return s\n\nh, w, a, b = map(int, input().split())\nmod = pow(10, 9) + 7\nx = h -... | def permutation(n, k, mod):
s = 1
for _ in range(k):
s *= n
s %= mod
n -= 1
return s
def factorial(n, mod):
s = 1
for i in range(1, n + 1):
s *= i
s %= mod
return s
h, w, a, b = map(int, input().split())
mod = pow(10, 9) + 7
x = h - a + b - 1
y = w - b +... |
[
7,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
2,
17,
17,... | [
[
40,
6
],
[
40,
9
],
[
38,
10
],
[
15,
14
],
[
40,
17
],
[
38,
19
],
[
40,
20
],
[
38,
27
],
[
14,
30
],
[
40,
30
],
[
38,
34
],
[
14,
35
],
[
40,
35
],
[
... | [
"#縦H A\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 #出力の制限\nN = (10**5)*2\ng1 = [1, 1] # 元テーブル\ng2 = [1, 1] #逆元テーブル\ninverse = [0, 1] #逆元テーブル計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod... | #縦H A
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = (10**5)*2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.appen... |
[
7,
12,
13,
42,
13,
0,
13,
13,
13,
2,
13,
13,
29,
13,
23,
13,
23,
13,
12,
13,
0,
39,
13,
13,
39,
17,
17,
0,
39,
13,
13,
39,
17,
17,
42,
40,
13,
17,
0,
13,
2,
13,
13,
0,
39,
13,
13,
39,
13,
2,
13,
13,
0,
39,
13... | [
[
7,
6
],
[
17,
7
],
[
8,
7
],
[
9,
8
],
[
6,
10
],
[
15,
10
],
[
17,
11
],
[
8,
11
],
[
6,
13
],
[
15,
13
],
[
15,
15
],
[
17,
17
],
[
24,
21
],
[
31,
... | [
"def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n\ndef egcd(a, b):\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return (lastx, lasty, a)\n\n# a... | def gcd(a, b):
while b:
a, b = b, a % b
return a
def egcd(a, b):
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
(a, b) = (b, a % b)
(x, lastx) = (lastx - q * x, x)
(y, lasty) = (lasty - q * y, y)
return (lastx, lasty, a)
# ax ≡ 1 (mod m)
def modinv... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
2,
17,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
... | [
[
196,
2
],
[
196,
11
],
[
196,
12
],
[
196,
13
],
[
181,
15
],
[
175,
24
],
[
190,
31
],
[
182,
36
],
[
42,
39
],
[
191,
40
],
[
47,
44
],
[
191,
45
],
[
50,
49
... | [
"H, W, A, B = map(int, input().split())\n\nMAX = 2 * 10 ** 5 + 1\nMOD = 10 ** 9 + 7\n\n# Factorial\nfac = [0] * (MAX + 1)\nfac[0] = 1\nfac[1] = 1\nfor i in range(2, MAX + 1):\n fac[i] = fac[i - 1] * i % MOD\n \n# Inverse factorial\nfinv = [0] * (MAX + 1)\nfinv[MAX] = pow(fac[MAX], MOD - 2, MOD)\nfor i in reve... | H, W, A, B = map(int, input().split())
MAX = 2 * 10 ** 5 + 1
MOD = 10 ** 9 + 7
# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
fac[i] = fac[i - 1] * i % MOD
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + ... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
4,
13,
13,
2,
13,
17,
13,
0,
13,
2,
... | [
[
303,
2
],
[
303,
11
],
[
303,
12
],
[
303,
13
],
[
276,
15
],
[
309,
22
],
[
274,
24
],
[
298,
25
],
[
279,
27
],
[
310,
32
],
[
36,
35
],
[
310,
40
],
[
46,
43
... | [
"H,W,A,B=map(int,input().split())\n\nmod=10**9+7\n\nn=H+W\nINV=[None]*(n+1)#1/aのリストを予め作っておく.\nfor i in range(1,n+1):\n INV[i]=pow(i,mod-2,mod)\n\nk=H+W-2\nn=H-1\nCombi1=[None]*(k+1)#Combi[i]=iCnを表す.kは必要な分だけ.\nCombi1[n]=1\nfor i in range(n+1,k+1):\n Combi1[i]=Combi1[i-1]*i*INV[i-n] %mod\n\nk=H+B-2\nn=B-1\nComb... | H,W,A,B=map(int,input().split())
mod=10**9+7
n=H+W
INV=[None]*(n+1)#1/aのリストを予め作っておく.
for i in range(1,n+1):
INV[i]=pow(i,mod-2,mod)
k=H+W-2
n=H-1
Combi1=[None]*(k+1)#Combi[i]=iCnを表す.kは必要な分だけ.
Combi1[n]=1
for i in range(n+1,k+1):
Combi1[i]=Combi1[i-1]*i*INV[i-n] %mod
k=H+B-2
n=B-1
Combi2=[None]*(k+1)#Combi[i... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
12,
13,
0,
13,
39,
17,
17,
13,
0,
13,
39,
17,
17,
13,
42,
40,
18,
13,
17,
17,
0,
13,
2,
18,
13,
17,
18,
13,
17,
0,
13,
13,
0,
13,
39,
2,
18,
13,
17,
2,
13,
... | [
[
271,
2
],
[
271,
11
],
[
271,
12
],
[
271,
13
],
[
18,
17
],
[
24,
23
],
[
23,
31
],
[
80,
31
],
[
36,
35
],
[
17,
38
],
[
77,
38
],
[
23,
41
],
[
80,
41
],
[... | [
"H,W,A,B=map(int,input().split())\ndef extgcd(a,b):\n r = [1,0,a]\n w = [0,1,b]\n while w[2]!=1:\n q = r[2]//w[2]\n r2 = w\n w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]\n r = r2\n w = w2\n #[x,y]\n return [w[0],w[1]]\ndef mod_inv(a,m):\n x = extgcd(a,m)[0]\n re... | H,W,A,B=map(int,input().split())
def extgcd(a,b):
r = [1,0,a]
w = [0,1,b]
while w[2]!=1:
q = r[2]//w[2]
r2 = w
w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
r = r2
w = w2
#[x,y]
return [w[0],w[1]]
def mod_inv(a,m):
x = extgcd(a,m)[0]
return (m+x%m)%m
def ... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17,
28,
13,
4,
13,
17,
2,
13,
13,
0,
18,
13,
13,
... | [
[
180,
2
],
[
180,
11
],
[
180,
12
],
[
180,
13
],
[
174,
15
],
[
186,
18
],
[
177,
25
],
[
160,
31
],
[
163,
32
],
[
168,
35
],
[
160,
41
],
[
163,
42
],
[
46,
45
... | [
"h,w,a,b=map(int,input().split())\nans = 0\n\nmod = 10**9 + 7\nfac = [1] * (h+w+1)\ninv = [1] * (h+w+1)\nfor i in range(1,h+w):\n fac[i] = (fac[i-1] * i)%mod\n inv[i] = pow(fac[i], mod-2, mod)\n\ndef cmb(n,r):\n return fac[n] * inv[r] * inv[n-r] % mod\n \nfor x in range(b,w):\n c = x + (h - a - 1)\n ... | h,w,a,b=map(int,input().split())
ans = 0
mod = 10**9 + 7
fac = [1] * (h+w+1)
inv = [1] * (h+w+1)
for i in range(1,h+w):
fac[i] = (fac[i-1] * i)%mod
inv[i] = pow(fac[i], mod-2, mod)
def cmb(n,r):
return fac[n] * inv[r] * inv[n-r] % mod
for x in range(b,w):
c = x + (h - a - 1)
d = (w - x - 1) +... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
13,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
13,
0,
13,
13,
0,
18,
13,
... | [
[
226,
2
],
[
226,
11
],
[
226,
12
],
[
226,
13
],
[
208,
15
],
[
206,
18
],
[
182,
19
],
[
172,
22
],
[
190,
29
],
[
209,
34
],
[
223,
37
],
[
41,
40
],
[
209,
45
... | [
"H,W,A,B=map(int,input().split())\nN=H+W+2\nmod=10**9+7\ntable=[1]*(N+3)\nt=1\nfor i in range(1,N+3):\n t*=i\n t%=mod\n table[i]=t\nrtable=[1]*(N+3)\nt=1\nfor i in range(1,N+3):\n t*=pow(i,mod-2,mod)\n t%=mod\n rtable[i]=t\nans=0\nfor i in range(H-A):\n t=table[B-1+i]*rtable[i]*rtable[B-1]\n ... | H,W,A,B=map(int,input().split())
N=H+W+2
mod=10**9+7
table=[1]*(N+3)
t=1
for i in range(1,N+3):
t*=i
t%=mod
table[i]=t
rtable=[1]*(N+3)
t=1
for i in range(1,N+3):
t*=pow(i,mod-2,mod)
t%=mod
rtable[i]=t
ans=0
for i in range(H-A):
t=table[B-1+i]*rtable[i]*rtable[B-1]
s=table[W+H-B-i-2]*rta... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
12,
13,
14,
2,
13,
17,
14,
2,
13,
17,
14,
2,
2,
13,
17,
17,
23,
13,
23,
13,
0,
13,
39,
17,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
4,
18,
13,
13,
2... | [
[
244,
2
],
[
244,
11
],
[
244,
12
],
[
244,
13
],
[
223,
15
],
[
36,
21
],
[
36,
25
],
[
36,
30
],
[
34,
34
],
[
36,
36
],
[
220,
38
],
[
43,
42
],
[
239,
48
],
... | [
"h, w, a, b = map(int, input().split())\nmod = 1000000007\n\ndef modpow(x, y): \n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return modpow(x, y//2)**2 % mod\n else : return modpow(x, y//2)**2 * x % mod\n\nstairs = [1]\nfor i in range(1, h+w+1):\n st... | h, w, a, b = map(int, input().split())
mod = 1000000007
def modpow(x, y):
if y == 0 : return 1
elif y == 1 : return x % mod
elif y % 2 == 0 : return modpow(x, y//2)**2 % mod
else : return modpow(x, y//2)**2 * x % mod
stairs = [1]
for i in range(1, h+w+1):
stairs.append(stai... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
41,
28,
13,
2,
39,
17,
17,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
17,
0,
18,
13,
13,
2,
2,
13,
18,
13,
2,
13,
17,
2,
2,
17,
17,
17,
12,
13... | [
[
147,
2
],
[
147,
11
],
[
147,
12
],
[
147,
13
],
[
17,
16
],
[
150,
24
],
[
30,
27
],
[
151,
28
],
[
33,
32
],
[
41,
38
],
[
151,
39
],
[
32,
40
],
[
32,
43
],
... | [
"h,w,a,b=map(int,input().split())\nn_func=[None for _ in [0]*200001]\nn_func[0]=1\nfor i in range(1,200001):\n n_func[i]=(i*n_func[i-1])%(10**9+7)\ndef inv_n(n,mod=10**9+7):return pow(n,mod-2,mod)\ndef nCr(n,r,mod=10**9+7):return inv_n(n_func[n-r]*n_func[r]%mod,mod)*n_func[n]%mod\n\ncnt=0\nfor i in range(h-a):\n... | h,w,a,b=map(int,input().split())
n_func=[None for _ in [0]*200001]
n_func[0]=1
for i in range(1,200001):
n_func[i]=(i*n_func[i-1])%(10**9+7)
def inv_n(n,mod=10**9+7):return pow(n,mod-2,mod)
def nCr(n,r,mod=10**9+7):return inv_n(n_func[n-r]*n_func[r]%mod,mod)*n_func[n]%mod
cnt=0
for i in range(h-a):
cnt=(cnt+nC... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
2,
17,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
2,
2,
18,
... | [
[
243,
2
],
[
243,
11
],
[
243,
12
],
[
243,
13
],
[
252,
15
],
[
216,
22
],
[
31,
30
],
[
217,
34
],
[
246,
39
],
[
43,
42
],
[
217,
47
],
[
53,
50
],
[
247,
51
... | [
"H, W, A, B = map(int, input().split())\nmod = 10**9 + 7\nU = 2 * 10**5\n\nfactorial = [1 for _ in range(U + 1)]\nfor i in range(1, U + 1):\n factorial[i] = (factorial[i - 1] * i) % mod\n\ninverse = [1 for _ in range(U + 1)]\ninverse[U] = pow(factorial[U], mod - 2, mod)\nfor i in range(U, 0, -1):\n inverse[i ... | H, W, A, B = map(int, input().split())
mod = 10**9 + 7
U = 2 * 10**5
factorial = [1 for _ in range(U + 1)]
for i in range(1, U + 1):
factorial[i] = (factorial[i - 1] * i) % mod
inverse = [1 for _ in range(U + 1)]
inverse[U] = pow(factorial[U], mod - 2, mod)
for i in range(U, 0, -1):
inverse[i - 1] = (inverse[... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
13,
0,
13,
13,
4,
18,
13,
13,
13,
0,
13,
4,
13,
13,
2,
13,
... | [
[
200,
2
],
[
200,
11
],
[
200,
12
],
[
200,
13
],
[
194,
15
],
[
25,
24
],
[
28,
27
],
[
32,
31
],
[
96,
36
],
[
40,
39
],
[
31,
40
],
[
43,
42
],
[
98,
43
],
... | [
"H, W, A, B = map(int,input().split())\nMOD = 10**9 + 7\ndef prepare(n, MOD):\n\n # 1! - n! の計算\n f = 1\n factorials = [1] # 0!の分\n for m in range(1, n + 1):\n f *= m\n f %= MOD\n factorials.append(f)\n # n!^-1 の計算\n inv = pow(f, MOD - 2, MOD)\n # n!^-1 - 1!^-1 の計算\n in... | H, W, A, B = map(int,input().split())
MOD = 10**9 + 7
def prepare(n, MOD):
# 1! - n! の計算
f = 1
factorials = [1] # 0!の分
for m in range(1, n + 1):
f *= m
f %= MOD
factorials.append(f)
# n!^-1 の計算
inv = pow(f, MOD - 2, MOD)
# n!^-1 - 1!^-1 の計算
invs = [1] * (n + 1)
... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
... | [
[
196,
4
],
[
193,
11
],
[
197,
18
],
[
193,
20
],
[
193,
21
],
[
193,
22
],
[
199,
24
],
[
202,
31
],
[
211,
34
],
[
203,
39
],
[
214,
42
],
[
203,
47
],
[
51,
50
... | [
"import sys\ninput = sys.stdin.readline\nH,W,A,B= map(int,input().split())\n\nMOD = 10**9 + 7\nnum = 200010\nfact = [1] * (num+1)\nifact = [1] * (num+1)\n\nfor i in range(1,num+1):\n fact[i] = (fact[i-1] * i) % MOD\nifact[-1] = pow(fact[-1],MOD-2,MOD)\nfor i in range(1,num+1)[::-1]:\n ifact[i-1] = (ifact[i] *... | import sys
input = sys.stdin.readline
H,W,A,B= map(int,input().split())
MOD = 10**9 + 7
num = 200010
fact = [1] * (num+1)
ifact = [1] * (num+1)
for i in range(1,num+1):
fact[i] = (fact[i-1] * i) % MOD
ifact[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(1,num+1)[::-1]:
ifact[i-1] = (ifact[i] * i)% MOD
def nCr(... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
28,
13,
4,
13,
2,
13,
13,
4,
18,
13,
13,
2,
2,
18,
13,
13,
2,
13,
17,
13,
12,
13,
29,
2,
2,
2,
18,
13,
13,
4,
13,
... | [
[
151,
2
],
[
151,
11
],
[
151,
12
],
[
151,
13
],
[
139,
15
],
[
148,
22
],
[
27,
26
],
[
143,
30
],
[
152,
31
],
[
149,
34
],
[
149,
39
],
[
26,
40
],
[
26,
42
... | [
"h,w,a,b = map(int,input().split()) #入力\nmod = 10**9+7 \n\n#前計算 f[i] = i!\nf=[1]\nfor i in range(h+w):\n f.append(f[i]*(i+1)%mod)\n\n#C(n,r,p) = ( n! * r!^(p-2) * (n-r)!^(p-2) )%p\n#pythonだとpow()で二分累乗法が使える\ndef comb(n, r, p):\n return f[n] * pow(f[r], p-2, p) * pow(f[n-r], p-2, p) % p\n\n#紫点ごとに調べる\nans=0\nfor i i... | h,w,a,b = map(int,input().split()) #入力
mod = 10**9+7
#前計算 f[i] = i!
f=[1]
for i in range(h+w):
f.append(f[i]*(i+1)%mod)
#C(n,r,p) = ( n! * r!^(p-2) * (n-r)!^(p-2) )%p
#pythonだとpow()で二分累乗法が使える
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(b, w):
ans... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
2,
2,
1... | [
[
186,
2
],
[
186,
11
],
[
186,
12
],
[
186,
13
],
[
198,
15
],
[
187,
17
],
[
172,
18
],
[
192,
20
],
[
177,
27
],
[
199,
32
],
[
183,
35
],
[
199,
40
],
[
44,
43
... | [
"h, w, a, b = map(int, input().split())\nm = h + w\nmod = 10 ** 9 + 7\n\nfac = [1] * (m + 1)\ninv = [1] * (m + 1)\nfor i in range(1, m + 1):\n fac[i] = fac[i - 1] * i % mod\ninv[-1] = pow(fac[-1], mod - 2, mod)\nfor i in range(m - 1, -1, -1):\n inv[i] = inv[i + 1] * (i + 1) % mod\n\n\ndef cmb(n, r):\n asse... | h, w, a, b = map(int, input().split())
m = h + w
mod = 10 ** 9 + 7
fac = [1] * (m + 1)
inv = [1] * (m + 1)
for i in range(1, m + 1):
fac[i] = fac[i - 1] * i % mod
inv[-1] = pow(fac[-1], mod - 2, mod)
for i in range(m - 1, -1, -1):
inv[i] = inv[i + 1] * (i + 1) % mod
def cmb(n, r):
assert n >= r >= 0
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
2,
13,
13,
17,
0,
13,
13,
12,
13,
0,
13,
39,
17,
28,
13,
4,
13,
17,
13,
4,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
13,
... | [
[
256,
2
],
[
256,
11
],
[
256,
12
],
[
256,
13
],
[
238,
15
],
[
223,
22
],
[
257,
25
],
[
221,
26
],
[
232,
29
],
[
251,
30
],
[
35,
34
],
[
39,
38
],
[
38,
42
... | [
"H, W, A, B = map(int, input().split())\nMOD = 10 ** 9 + 7\n\ni = H - A - 1\nj = B\n\n\n# 階乗とその逆元を事前計算する (O(N))\n# finv[0] := 0の階乗の逆元\ndef factorial_and_inv(n, mod=10 ** 9 + 7):\n f = [1]\n for n in range(1, n):\n f.append(f[n - 1] * n % mod)\n finv = [0] * n\n finv[n - 1] = pow(f[n - 1], mod - 2... | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
i = H - A - 1
j = B
# 階乗とその逆元を事前計算する (O(N))
# finv[0] := 0の階乗の逆元
def factorial_and_inv(n, mod=10 ** 9 + 7):
f = [1]
for n in range(1, n):
f.append(f[n - 1] * n % mod)
finv = [0] * n
finv[n - 1] = pow(f[n - 1], mod - 2, mod)
for n in... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
2,
13,
17,
0,
13,
17,
42,
2,
13,
17,
14,
2,
2,
13,
17,
17,
0,
13,
2,
2,
13,
13,
13,
0,
13,
2,
2,
13,
17,
13,
0,
1... | [
[
317,
2
],
[
317,
11
],
[
317,
12
],
[
317,
13
],
[
305,
15
],
[
25,
24
],
[
63,
26
],
[
30,
29
],
[
24,
33
],
[
56,
33
],
[
24,
38
],
[
56,
38
],
[
43,
42
],
... | [
"h, w, a, b = map(int,input().split())\nmod = 10**9 + 7\n\ndef inv(x, p):\n pp = p-2\n ans = 1\n while pp > 0:\n if pp % 2 == 1:\n ans = (ans * x) % p\n x = (x ** 2) % p\n pp //= 2\n return ans\n\nI = [1] + [inv(i, mod) for i in range(1, h+w+1)]\n\na0 = 1\na1 = 1\nfor i i... | 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+... |
[
7,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
2,
17,... | [
[
40,
6
],
[
40,
9
],
[
38,
10
],
[
15,
14
],
[
40,
17
],
[
38,
19
],
[
40,
20
],
[
38,
27
],
[
14,
30
],
[
40,
30
],
[
38,
34
],
[
14,
35
],
[
40,
35
],
[
... | [
"def cmb(n, r, mod):#コンビネーションの高速計算 \n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 #出力の制限\nN = 2*10**5\ng1 = [1, 1] # 元テーブル\ng2 = [1, 1] #逆元テーブル\ninverse = [0, 1] #逆元テーブル計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) %... | 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 = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse... |
[
7,
15,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
12,
13,
0,
13,
13,
0,
13,
13,
29,
2,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
13,
0,
13,
13,
29,
2,
2,
13,
4,
13,
... | [
[
25,
24
],
[
40,
25
],
[
28,
27
],
[
40,
28
],
[
24,
32
],
[
36,
32
],
[
27,
33
],
[
38,
33
],
[
40,
34
],
[
36,
36
],
[
38,
38
],
[
40,
40
],
[
45,
44
],
[
... | [
"#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nimport sys\n\n\ndef get_ints():\n return map(int, sys.stdin.readline().strip().split())\n\n\ndef mul(x, y, mod):\n x %= mod\n y %= mod\n return x * y % mod\n\n\ndef div(x, y, mod):\n x %= mod\n y %= mod\n return x * mod_pow(y, mod - 2, mod) % mod\n... | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def mul(x, y, mod):
x %= mod
y %= mod
return x * y % mod
def div(x, y, mod):
x %= mod
y %= mod
return x * mod_pow(y, mod - 2, mod) % mod
def mod_pow(a, p, mod):... |
[
7,
6,
13,
12,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
2,
17,
17,
0,
18,
13,
13,
2,
39,
17,
13,
0,
18,
13,
13,
2,
39,
17,
13,
0,
18,
13,
13,
2,
39,
17,
13,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13... | [
[
8,
7
],
[
15,
14
],
[
24,
21
],
[
145,
22
],
[
14,
27
],
[
32,
29
],
[
145,
30
],
[
14,
35
],
[
40,
37
],
[
145,
38
],
[
14,
43
],
[
57,
45
],
[
21,
46
],
[
... | [
"class CombinationFermat:\n\n def __init__(self):\n \"\"\"O(MAX)で前計算しておく→以降comb(a,b)はO(1)で取得可能\n \"\"\"\n MOD = 10**9 + 7\n MAX = 2*10**5\n\n self.fac = [0]*MAX # self.fac[n]: (n!) mod p\n self.finv = [0]*MAX # self.finv[n]: (n!)^-1 mod p\n self.inv = [0]*MAX ... | class CombinationFermat:
def __init__(self):
"""O(MAX)で前計算しておく→以降comb(a,b)はO(1)で取得可能
"""
MOD = 10**9 + 7
MAX = 2*10**5
self.fac = [0]*MAX # self.fac[n]: (n!) mod p
self.finv = [0]*MAX # self.finv[n]: (n!)^-1 mod p
self.inv = [0]*MAX # inv[n]: (n)^-1 m... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
2,
13,
13,
4,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
13,
12,
13,
0,
13,
17,
42,
2,
13,
17,
14,... | [
[
237,
2
],
[
237,
11
],
[
237,
12
],
[
237,
13
],
[
228,
15
],
[
204,
22
],
[
27,
26
],
[
220,
31
],
[
238,
32
],
[
205,
35
],
[
205,
40
],
[
26,
42
],
[
26,
44
... | [
"h, w, a, b = map(int, input().split())\n\nmod = 10**9+7\nfac = [1]\nfor n in range(1, h+w):\n\tfac.append(fac[n-1]*n%mod)\n\ndef modpow(a,n,mod):\n\tr=1\n\twhile n>0:\n\t\tif n&1:\tr = r*(a%mod)\n\t\ta *= a%mod\n\t\tn >>= 1\n\treturn r\n\ninvfac = [0] * (h+w)\ninvfac[h+w-1] = modpow(fac[h+w-1], mod-2, mod)\nfor n ... | h, w, a, b = map(int, input().split())
mod = 10**9+7
fac = [1]
for n in range(1, h+w):
fac.append(fac[n-1]*n%mod)
def modpow(a,n,mod):
r=1
while n>0:
if n&1: r = r*(a%mod)
a *= a%mod
n >>= 1
return r
invfac = [0] * (h+w)
invfac[h+w-1] = modpow(fac[h+w-1], mod-2, mod)
for n in range(h+w-2, -1, -1):
invfac[... |
[
7,
15,
13,
15,
0,
13,
2,
2,
17,
17,
17,
14,
2,
13,
17,
0,
39,
13,
13,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
39,
17,
2,
13,
13,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
13,
0,
... | [
[
198,
5
],
[
21,
16
],
[
204,
30
],
[
41,
38
],
[
205,
39
],
[
46,
43
],
[
205,
44
],
[
207,
48
],
[
59,
56
],
[
208,
57
],
[
64,
61
],
[
208,
62
],
[
67,
66
],
... | [
"import operator as op\nfrom functools import reduce\n\nMODULUS = 10**9 + 7\n\nif __name__ == '__main__':\n [h, w, a, b] = map(int, input().split())\n\n # Taken from https://atcoder.jp/contests/abc042/submissions/3178794 for learning purposes.\n factorial = [0] * (h+w)\n factorial[0] = 1\n factorial[... | import operator as op
from functools import reduce
MODULUS = 10**9 + 7
if __name__ == '__main__':
[h, w, a, b] = map(int, input().split())
# Taken from https://atcoder.jp/contests/abc042/submissions/3178794 for learning purposes.
factorial = [0] * (h+w)
factorial[0] = 1
factorial[1] = 1
inver... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
0,
13,
2,
2,
2,
13,
2,
2,
2,
2,
13,
13,
13,
17,
13,
4,
13,
2,
13,
17,
2,
13,
17,... | [
[
124,
2
],
[
142,
9
],
[
142,
18
],
[
142,
19
],
[
142,
20
],
[
112,
22
],
[
130,
25
],
[
29,
28
],
[
128,
32
],
[
136,
35
],
[
113,
39
],
[
119,
39
],
[
116,
44
... | [
"M=10**9+7\nH,W,A,B = map(int,input().split())\nC = 1\nans = 1\n\nfor I in range(H-1):\n ans = C = C*(W+H-B-2-I)*pow(I+1,M-2,M)%M\n\nfor I in range(1,H-A):\n C = C*(B-1+I)*(H-I)*pow(I*(W+H-B-1-I),M-2,M)%M\n ans+=C\n\nprint(ans%M)",
"M=10**9+7",
"M",
"10**9+7",
"10**9",
"10",
"9",
"7",
"H,W,A,B = ... | M=10**9+7
H,W,A,B = map(int,input().split())
C = 1
ans = 1
for I in range(H-1):
ans = C = C*(W+H-B-2-I)*pow(I+1,M-2,M)%M
for I in range(1,H-A):
C = C*(B-1+I)*(H-I)*pow(I*(W+H-B-1-I),M-2,M)%M
ans+=C
print(ans%M) |
[
7,
0,
13,
2,
2,
17,
17,
17,
41,
28,
13,
4,
13,
17,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
17,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
17,
4,
17,
0,
13,
13,
28,
13,
4,
13,
17,
17,
0,
18,
13,
13,
2,
2,
18,
13,
2,
... | [
[
209,
2
],
[
11,
10
],
[
206,
17
],
[
22,
21
],
[
200,
28
],
[
33,
32
],
[
191,
39
],
[
43,
42
],
[
51,
48
],
[
207,
49
],
[
42,
50
],
[
207,
54
],
[
42,
56
],
... | [
"MOD = 10**9+7\nfac = [1 for k in range(200010)]\ninv = [1 for k in range(200010)]\nfinv = [1 for k in range(200010)]\nfor k in range(2,200010):\n fac[k] = (fac[k-1]*k)%MOD\n inv[k] = (MOD - inv[MOD%k] * (MOD // k))%MOD\n finv[k] = (finv[k - 1] * inv[k]) % MOD;\ndef nCr(n,r):\n return (fac[n]*finv[r]*fi... | MOD = 10**9+7
fac = [1 for k in range(200010)]
inv = [1 for k in range(200010)]
finv = [1 for k in range(200010)]
for k in range(2,200010):
fac[k] = (fac[k-1]*k)%MOD
inv[k] = (MOD - inv[MOD%k] * (MOD // k))%MOD
finv[k] = (finv[k - 1] * inv[k]) % MOD;
def nCr(n,r):
return (fac[n]*finv[r]*finv[n-r])%MOD
... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
4,
18,
13,
13,
2,
2,
18,
13,
13,
2,
13,
17,
13,
4,
18,
13,
13,
4,
13,
18,
13,
2,
13,
17,
2,
13,
17,
13,
12,
13,
14,
2,
2,
2,
13,
... | [
[
169,
2
],
[
163,
9
],
[
181,
13
],
[
18,
17
],
[
164,
23
],
[
164,
28
],
[
17,
29
],
[
17,
31
],
[
170,
33
],
[
182,
36
],
[
164,
41
],
[
17,
43
],
[
170,
46
],... | [
"mod = 10 ** 9 + 7\nfact = [1]\ninv = [1]\nfor i in range(200000):\n fact.append(fact[i] * (i + 1) % mod)\n inv.append(pow(fact[i + 1], mod - 2, mod))\ndef ncr(n, r):\n if n < 0 or r < 0 or n - r < 0:\n return 0\n return fact[n] * inv[r] * inv[n - r] % mod\nh, w, a, b = map(int, input().split())\nans = ncr(h... | mod = 10 ** 9 + 7
fact = [1]
inv = [1]
for i in range(200000):
fact.append(fact[i] * (i + 1) % mod)
inv.append(pow(fact[i + 1], mod - 2, mod))
def ncr(n, r):
if n < 0 or r < 0 or n - r < 0:
return 0
return fact[n] * inv[r] * inv[n - r] % mod
h, w, a, b = map(int, input().split())
ans = ncr(h + w - 2, h - 1)... |
[
7,
15,
13,
13,
15,
15,
15,
15,
15,
15,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
... | [
[
24,
23
],
[
253,
29
],
[
33,
33
],
[
213,
42
],
[
243,
47
],
[
246,
54
],
[
249,
61
],
[
247,
66
],
[
70,
69
],
[
247,
74
],
[
80,
77
],
[
250,
78
],
[
69,
79
]... | [
"import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, ... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from ... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
2,
17,
17,
0,
13,
2,
39,
17,
13,
12,
13,
28,
13,
4,
13,
17,
13,
0,
18,
13,
13,
2,
2,
13,
18,
13,
2,
13,
17,
13,
12,
... | [
[
207,
2
],
[
207,
11
],
[
207,
12
],
[
207,
13
],
[
198,
15
],
[
210,
22
],
[
189,
29
],
[
211,
33
],
[
38,
37
],
[
211,
41
],
[
46,
43
],
[
190,
44
],
[
37,
45
... | [
"h, w, a, b = map(int, input().split())\n###############\n# 二項係数テンプレート\n# 出力制限\nmod = 10 ** 9 + 7\nMAX_N = 2 * 10 ** 5\nfactorial = [1] * MAX_N\n#事前に階乗テーブルを用意\ndef calc_factorial():\n for i in range(1, MAX_N):\n factorial[i] = i * factorial[i - 1] % mod\n\ndef comb(n, k):\n a = factorial[n] % mod\n ... | h, w, a, b = map(int, input().split())
###############
# 二項係数テンプレート
# 出力制限
mod = 10 ** 9 + 7
MAX_N = 2 * 10 ** 5
factorial = [1] * MAX_N
#事前に階乗テーブルを用意
def calc_factorial():
for i in range(1, MAX_N):
factorial[i] = i * factorial[i - 1] % mod
def comb(n, k):
a = factorial[n] % mod
b = (factorial[k] *... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
2,
39,
17,
13,
13,
2,
39,
17,
13,
13,
2,
39,
17,
13,
28,
13,
4,
13,
17,
13,
0,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
13,
0,
18,
13,
13,
2,
13,
2,
2,
1... | [
[
225,
4
],
[
14,
13
],
[
85,
17
],
[
19,
18
],
[
85,
22
],
[
24,
23
],
[
85,
27
],
[
30,
29
],
[
85,
33
],
[
38,
35
],
[
13,
36
],
[
29,
37
],
[
13,
41
],
[
... | [
"# python3 (3.4.3)\nimport sys\ninput = sys.stdin.readline\n\n# functions\ndef init_fact(n,mod):\n fact,finv,inv = [1]*n,[1]*n,[1]*n\n for i in range(2,n):\n fact[i] = (fact[i-1]*i) % mod\n inv[i] = mod - inv[mod%i] * (mod//i)%mod\n finv[i] = finv[i-1] * inv[i] % mod\n return (fact,fi... | # python3 (3.4.3)
import sys
input = sys.stdin.readline
# functions
def init_fact(n,mod):
fact,finv,inv = [1]*n,[1]*n,[1]*n
for i in range(2,n):
fact[i] = (fact[i-1]*i) % mod
inv[i] = mod - inv[mod%i] * (mod//i)%mod
finv[i] = finv[i-1] * inv[i] % mod
return (fact,finv,inv)
def nCr... |
[
7,
15,
13,
13,
13,
15,
15,
15,
15,
15,
15,
15,
12,
13,
14,
13,
4,
13,
31,
13,
23,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
23,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
13,... | [
[
40,
40
],
[
42,
42
],
[
331,
51
],
[
367,
56
],
[
346,
63
],
[
319,
74
],
[
376,
85
],
[
126,
92
],
[
124,
95
],
[
126,
96
],
[
101,
100
],
[
126,
103
],
[
124,
1... | [
"import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom s... | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string impor... |
[
7,
0,
13,
2,
2,
17,
2,
17,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
1... | [
[
207,
2
],
[
213,
11
],
[
201,
18
],
[
208,
23
],
[
27,
26
],
[
208,
31
],
[
37,
34
],
[
202,
35
],
[
26,
36
],
[
202,
40
],
[
26,
42
],
[
26,
44
],
[
214,
45
],... | [
"N=2*10**5+3\nmod=10**9+7\nfac=[1]*(N+1)\nfor i in range(1,N+1):\n fac[i]=fac[i-1]*i%mod\ninv_fac=[1]*(N+1)\ninv_fac[N]=pow(fac[N],mod-2,mod)\nfor i in range(N-1,0,-1):\n inv_fac[i]=inv_fac[i+1]*(i+1)%mod\ndef nCr(n,r):\n if n<0 or r<0 or r>n:\n return 0\n return fac[n]*inv_fac[r]%mod*inv_fac[n-r... | N=2*10**5+3
mod=10**9+7
fac=[1]*(N+1)
for i in range(1,N+1):
fac[i]=fac[i-1]*i%mod
inv_fac=[1]*(N+1)
inv_fac[N]=pow(fac[N],mod-2,mod)
for i in range(N-1,0,-1):
inv_fac[i]=inv_fac[i+1]*(i+1)%mod
def nCr(n,r):
if n<0 or r<0 or r>n:
return 0
return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod
h,w,a,b=map... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
13,
13,
28,
13,
4,
13,
17,
2,
13,
17,
4,
18,
13,
13,
2,
2,
18,
... | [
[
189,
2
],
[
159,
9
],
[
186,
14
],
[
165,
19
],
[
198,
24
],
[
198,
33
],
[
198,
34
],
[
198,
35
],
[
174,
37
],
[
196,
39
],
[
172,
40
],
[
43,
42
],
[
175,
47
... | [
"mod=10**9+7\ng1=[1,1]\ng2=[1,1]\ninverse=[0,1]\nh,w,a,b=map(int,input().split())\nn=h+w\nfor i in range(2,n+1):\n g1.append((g1[-1]*i)%mod)\n inverse.append((-inverse[mod % i]*(mod//i))%mod)\n g2.append((g2[-1]*inverse[-1])%mod)\ndef cmb(n,r):\n return g1[n]*g2[r]*g2[n-r]%mod\n \nans=0\nwhile a<h and b... | mod=10**9+7
g1=[1,1]
g2=[1,1]
inverse=[0,1]
h,w,a,b=map(int,input().split())
n=h+w
for i in range(2,n+1):
g1.append((g1[-1]*i)%mod)
inverse.append((-inverse[mod % i]*(mod//i))%mod)
g2.append((g2[-1]*inverse[-1])%mod)
def cmb(n,r):
return g1[n]*g2[r]*g2[n-r]%mod
ans=0
while a<h and b<w:
ans=(ans+cm... |
[
7,
15,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
2,
2,
2,
13,
13,
13,
17,
2,
13,
13,
12,
13,
0,
13,
17,
42,
13,
14,
2,
13,
17,
0,
13,
2,
2,
13,
13,
... | [
[
268,
5
],
[
268,
15
],
[
268,
16
],
[
268,
17
],
[
259,
19
],
[
271,
26
],
[
251,
32
],
[
257,
33
],
[
269,
34
],
[
269,
37
],
[
257,
38
],
[
43,
42
],
[
72,
48
... | [
"from array import *\nimport time\nh, w, a, b = map(int, input().split(' '))\nMOD = 10**9 + 7\nMAX = max(h+w-a-1, a+w)\n\n\ndef modpow(a, b):\n res = 1\n while b:\n if (b & 1):\n res = (res * a) % MOD\n a = (a * a) % MOD\n b >>= 1\n return res\n\n\ndef nCr(n, r):\n if r =... | from array import *
import time
h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = max(h+w-a-1, a+w)
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:
... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
17,
0,
13,
39,
17,
28,
13,
4,
13,
2,
13,
13,
4,
18,
13,
13,
2,
2,
18,
13,
13,
2,
13,
17,
13,
12,
13,
29,
2,
2,
18,
... | [
[
5,
4
],
[
5,
13
],
[
5,
14
],
[
5,
15
],
[
18,
17
],
[
25,
24
],
[
28,
27
],
[
32,
31
],
[
4,
35
],
[
13,
36
],
[
27,
39
],
[
27,
44
],
[
31,
45
],
[
31,
... | [
"def main():\n H, W, A, B = map(int, input().split())\n mod = 10**9 + 7\n ans = 0\n\n # 予め階乗を計算しておく\n f = [1]\n for i in range(H+W):\n f.append(f[i]*(i+1)%mod)\n\n # 組み合わせ関数\n def comb_mod(n, r, p):\n return f[n] * pow(f[r], p-2, p) * pow(f[n-r], p-2, p)\n\n for i in range(H... | def main():
H, W, A, B = map(int, input().split())
mod = 10**9 + 7
ans = 0
# 予め階乗を計算しておく
f = [1]
for i in range(H+W):
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 +=... |
[
7,
6,
13,
12,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
39,
17,
17,
0,
18,
13,
13,
39,
17,
17,
0,
18,
13,
13,
39,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
18,
18,
13,
13,
13,
2,
2,
18,
18,
13,
... | [
[
9,
6
],
[
99,
7
],
[
101,
8
],
[
101,
9
],
[
14,
11
],
[
99,
12
],
[
103,
13
],
[
103,
14
],
[
19,
16
],
[
99,
17
],
[
26,
23
],
[
99,
24
],
[
33,
30
],
[
... | [
"class Combination():\n # コンストラクタ\n def __init__(self, N:int, P:int):\n self.N = N\n self.P = P\n\n # fact[i] = (i! mod P)\n self.fact = [1, 1] \n # factinv[i] = ((i!)^(-1) mod P)\n self.factinv = [1, 1]\n # factinv 計算用\n self.inv = [0, 1] \n\n ... | class Combination():
# コンストラクタ
def __init__(self, N:int, P:int):
self.N = N
self.P = P
# fact[i] = (i! mod P)
self.fact = [1, 1]
# factinv[i] = ((i!)^(-1) mod P)
self.factinv = [1, 1]
# factinv 計算用
self.inv = [0, 1]
for i in range(... |
[
7,
15,
13,
0,
13,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
28,
13,
4,
13,
17,
2,
2,
17,
2,
17,
17,
17,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
13,
4,
18,
13,
13,
2,
2,
40,
18,
13,
2,
13,
13... | [
[
183,
4
],
[
159,
7
],
[
162,
12
],
[
174,
17
],
[
23,
22
],
[
160,
35
],
[
160,
40
],
[
22,
42
],
[
184,
43
],
[
175,
46
],
[
175,
52
],
[
184,
54
],
[
22,
55
]... | [
"import math\np=1000000007\ng1=[1,1]\ng2=[1,1]\ninverse=[0,1]\nfor i in range(2,2*(10**5)+1):\n g1.append((g1[-1]*i)%p)\n inverse.append((-inverse[p%i]*(p//i))%p)\n g2.append((g2[-1]*inverse[-1])%p)\ndef cmb2(n, r, mod):\n if (r<0 or r>n):return 0\n r = min(r,n-r)\n return g1[n]*g2[r]*g2[n-r]%mod\... | import math
p=1000000007
g1=[1,1]
g2=[1,1]
inverse=[0,1]
for i in range(2,2*(10**5)+1):
g1.append((g1[-1]*i)%p)
inverse.append((-inverse[p%i]*(p//i))%p)
g2.append((g2[-1]*inverse[-1])%p)
def cmb2(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 chwp(h,w,p):
... |
[
7,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
17,
0,... | [
[
40,
6
],
[
38,
9
],
[
40,
10
],
[
15,
14
],
[
40,
17
],
[
38,
19
],
[
40,
20
],
[
38,
27
],
[
14,
30
],
[
40,
30
],
[
38,
34
],
[
14,
35
],
[
40,
35
],
[
... | [
"def nCr(n, r, mod):\n if r < 0 or n < r:\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % mod\n\n\nmod = 10 ** 9 + 7\nN = 10 ** 6\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % mod)\n inv.append((-inv[m... | def nCr(n, r, mod):
if r < 0 or n < r:
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n - r] % mod
mod = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
fact.append((fact[-1] * i) % mod)
inv.append((-inv[mod % i] * (mod // i)... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
13,
13,
12,
13,
14,
2,
13,
17,
14,
2,
13,
17,
14,
2,
2,
13,
17,
17,
23,
13,
23,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
13... | [
[
207,
2
],
[
207,
11
],
[
207,
12
],
[
207,
13
],
[
189,
15
],
[
187,
17
],
[
208,
18
],
[
38,
23
],
[
38,
27
],
[
38,
32
],
[
36,
36
],
[
38,
38
],
[
222,
40
],... | [
"h, w, a, b = map(int, input().split())\n\nN = h + w\n\ndef power(x, y):\n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y // 2) ** 2 % mod\n else : return power(x, y // 2) ** 2 * x % mod\n\nmod = 10 ** 9 + 7\n\nfactorial = [1]\nfor i in ran... | h, w, a, b = map(int, input().split())
N = h + w
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
mod = 10 ** 9 + 7
factorial = [1]
for i in range(1, N):
fact... |
[
7,
12,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
2,
2,
13,
13,
13,
0,
18,
13,
13,
13,
29,
13,
23,
13,
12,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
13,
4,
13,
18,
13... | [
[
5,
4
],
[
37,
9
],
[
13,
12
],
[
16,
15
],
[
37,
20
],
[
24,
23
],
[
12,
26
],
[
23,
26
],
[
15,
27
],
[
33,
30
],
[
4,
31
],
[
15,
32
],
[
23,
33
],
[
12... | [
"# ARC058D - いろはちゃんとマス目 / Iroha and a Grid (ABC042D)\ndef get_fact(lim):\n # compute a toble of factorials (1-idx)\n fact = [1] * (lim + 1)\n x = 1\n for i in range(1, lim + 1):\n x = (x * i) % MOD\n fact[i] = x\n return fact\n\n\ndef get_inv(lim):\n # compute a toble of inverse fact... | # ARC058D - いろはちゃんとマス目 / Iroha and a Grid (ABC042D)
def get_fact(lim):
# compute a toble of factorials (1-idx)
fact = [1] * (lim + 1)
x = 1
for i in range(1, lim + 1):
x = (x * i) % MOD
fact[i] = x
return fact
def get_inv(lim):
# compute a toble of inverse factorials (1-idx)
... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
0,
18,
13,
13,
2,
... | [
[
230,
2
],
[
236,
9
],
[
236,
18
],
[
236,
19
],
[
236,
20
],
[
227,
22
],
[
225,
28
],
[
237,
29
],
[
35,
32
],
[
228,
33
],
[
40,
37
],
[
228,
38
],
[
43,
42
]... | [
"mod = 10 ** 9 + 7\n\nH, W, A, B = map(int, input().split())\n\nfact = [-1] * (H + W + 1)\nfact[0] = 1\nfact[1] = 1\nfor x in range(2, H + W + 1):\n fact[x] = x * fact[x - 1] % mod\n\ninvs = [-1] * (H + W + 1)\ninvs[H + W] = pow(fact[H + W], mod - 2, mod)\nfor x in range(H + W - 1, 0, -1):\n invs[x] = invs[x ... | mod = 10 ** 9 + 7
H, W, A, B = map(int, input().split())
fact = [-1] * (H + W + 1)
fact[0] = 1
fact[1] = 1
for x in range(2, H + W + 1):
fact[x] = x * fact[x - 1] % mod
invs = [-1] * (H + W + 1)
invs[H + W] = pow(fact[H + W], mod - 2, mod)
for x in range(H + W - 1, 0, -1):
invs[x] = invs[x + 1] * (x + 1) % m... |
[
7,
15,
13,
12,
13,
0,
13,
17,
0,
13,
4,
13,
17,
4,
18,
13,
13,
2,
17,
17,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
... | [
[
7,
6
],
[
10,
9
],
[
39,
38
],
[
69,
43
],
[
47,
46
],
[
69,
51
],
[
57,
54
],
[
38,
55
],
[
46,
56
],
[
38,
60
],
[
46,
62
],
[
46,
64
],
[
71,
65
],
[
3... | [
"#!/usr/bin/env python3\n\nimport sys\n# import math\n# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits\n# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)\n# from operator impor... | #!/usr/bin/env python3
import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgette... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
13,
4,
18,
13,
13,
2,
2,
40,
18,
13,... | [
[
365,
2
],
[
344,
9
],
[
353,
14
],
[
305,
19
],
[
314,
24
],
[
30,
29
],
[
345,
34
],
[
354,
38
],
[
354,
43
],
[
29,
45
],
[
366,
46
],
[
315,
49
],
[
315,
55
... | [
"mod = 10 ** 9 + 7\nN = 10 ** 6\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append(fact[-1] * i % mod)\n inv.append((-inv[mod % i] * (mod // i)) % mod)\n factinv.append((factinv[-1] * inv[-1]) % mod)\n\ndef combi_mod(n, r, p):\n if (r < 0) or (n < r):\n retu... | mod = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
fact.append(fact[-1] * i % mod)
inv.append((-inv[mod % i] * (mod // i)) % mod)
factinv.append((factinv[-1] * inv[-1]) % mod)
def combi_mod(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r... |
[
7,
15,
15,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17... | [
[
42,
8
],
[
40,
11
],
[
42,
12
],
[
17,
16
],
[
42,
19
],
[
40,
21
],
[
42,
22
],
[
40,
29
],
[
16,
32
],
[
42,
32
],
[
40,
36
],
[
16,
37
],
[
42,
37
],
[
... | [
"from operator import mul\nfrom functools import reduce\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\np = 10 ** 9 + 7\nN = 10 ** 6\nfact = [1, 1] # fact[n] = (n! mod p)\nfactinv = [1, 1] # factinv[n] = ((n!)^(-1... | 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 ** 6
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv ... |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
12,
13,
0,
13,
17,
13,
17,
12,
13,
41,
14,
2,
13,
17,
0,
13,
17,
0,
13,
17,
29,
13,
0,
13,
4,
13,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
13,
0,
13,
2,
13,
2,
13,
13,
0,... | [
[
14,
13
],
[
16,
15
],
[
63,
22
],
[
26,
25
],
[
29,
28
],
[
61,
31
],
[
34,
33
],
[
63,
36
],
[
61,
38
],
[
63,
39
],
[
42,
41
],
[
61,
43
],
[
63,
44
],
[
... | [
"import sys\n\nsys.setrecursionlimit(10 ** 9)\n\n\ndef extgcd(a, b):\n x, y = 0, 0\n\n def f(a, b):\n nonlocal x, y\n if b == 0:\n x = 1\n y = 0\n\n return a\n\n g = f(b, a % b)\n q = a // b\n next_x = y\n y = x - q * y\n x = ne... | import sys
sys.setrecursionlimit(10 ** 9)
def extgcd(a, b):
x, y = 0, 0
def f(a, b):
nonlocal x, y
if b == 0:
x = 1
y = 0
return a
g = f(b, a % b)
q = a // b
next_x = y
y = x - q * y
x = next_x
return g
... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
17,
0,
13,
17,
0,
13,
39,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
13,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
13,
28,
13,
4,
13,
17,
13,
4,
18,
13,
13,
4,
13,
18,
13,
13,
2,
13... | [
[
207,
2
],
[
186,
9
],
[
171,
12
],
[
180,
15
],
[
198,
19
],
[
24,
23
],
[
172,
27
],
[
181,
30
],
[
181,
35
],
[
23,
37
],
[
208,
38
],
[
41,
40
],
[
172,
44
]... | [
"mod = 10**9+7\nmod2 = 998244353\nrng = 200001\nfctr = [1]\nfinv = [1]\nfor i in range(1,rng):\n fctr.append(fctr[-1]*i%mod)\nfor i in range(1,rng):\n finv.append(pow(fctr[i],mod-2,mod))\ndef cmb(n,k):\n if n<0 or k<0:\n return 0\n else:\n return fctr[n]*finv[n-k]*finv[k]%mod\nh,w,a,b = ma... | mod = 10**9+7
mod2 = 998244353
rng = 200001
fctr = [1]
finv = [1]
for i in range(1,rng):
fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
if n<0 or k<0:
return 0
else:
return fctr[n]*finv[n-k]*finv[k]%mod
h,w,a,b = map(int, input().spli... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
12,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
... | [
[
212,
4
],
[
215,
11
],
[
36,
24
],
[
40,
25
],
[
38,
27
],
[
42,
28
],
[
38,
30
],
[
40,
32
],
[
42,
33
],
[
216,
34
],
[
36,
36
],
[
38,
38
],
[
40,
40
],
[
... | [
"import sys\ninput=sys.stdin.readline\n\nmod = 10**9+7\ndef nCr(fact, inv, n, r):\n return fact[n] * inv[r] * inv[n-r] % mod\n\ndef main():\n H,W,A,B = map(int,input().split())\n fact = [1]\n for i in range(1, H+W+1):\n fact.append(fact[i-1] * i % mod)\n \n inv = [0] * (H+W+1)\n inv[H+W]... | import sys
input=sys.stdin.readline
mod = 10**9+7
def nCr(fact, inv, n, r):
return fact[n] * inv[r] * inv[n-r] % mod
def main():
H,W,A,B = map(int,input().split())
fact = [1]
for i in range(1, H+W+1):
fact.append(fact[i-1] * i % mod)
inv = [0] * (H+W+1)
inv[H+W] = pow(fact[H+W], m... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
4,
13,
17,
17,
17,
0,
13,
17,
0,
13,
39,
13,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
0,
13,
2,
2,
13,
13,
13,
4,
18,
13,
13,
13,
0,
13,
4,
... | [
[
5,
4
],
[
5,
13
],
[
5,
14
],
[
5,
15
],
[
18,
17
],
[
26,
25
],
[
29,
28
],
[
33,
32
],
[
4,
38
],
[
13,
39
],
[
43,
42
],
[
25,
45
],
[
42,
45
],
[
32,
... | [
"def main():\n\n H, W, A, B = map(int, input().split())\n mod = pow(10, 9) + 7\n\n v = 1\n fs = [v]\n for i in range(1, H+W-1):\n v = (v * i) % mod\n fs.append(v)\n\n v = invfactorial(H+W-2, mod)\n invfs = [v]\n for i in range(H+W-2, 0, -1):\n v = (v * i) % mod\n ... | def main():
H, W, A, B = map(int, input().split())
mod = pow(10, 9) + 7
v = 1
fs = [v]
for i in range(1, H+W-1):
v = (v * i) % mod
fs.append(v)
v = invfactorial(H+W-2, mod)
invfs = [v]
for i in range(H+W-2, 0, -1):
v = (v * i) % mod
invfs.append(v)
... |
[
7,
15,
13,
15,
13,
15,
13,
4,
18,
13,
13,
17,
15,
15,
15,
15,
15,
15,
15,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
39,
17,
2,
17,
17,
28,
13,
4,
13,
17,
2,
17,
17,
... | [
[
156,
20
],
[
174,
27
],
[
174,
36
],
[
174,
37
],
[
174,
38
],
[
153,
40
],
[
49,
48
],
[
59,
56
],
[
154,
57
],
[
48,
58
],
[
154,
62
],
[
48,
64
],
[
48,
66
]... | [
"#!/usr/bin/env python3\n#ABC42 D\n\nimport sys\nimport math\nimport bisect\nsys.setrecursionlimit(1000000000)\nfrom heapq import heappush, heappop\nfrom collections import defaultdict\nfrom itertools import accumulate\nfrom collections import Counter\nfrom collections import deque\nfrom operator import itemgetter\... | #!/usr/bin/env python3
#ABC42 D
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools im... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
39,
17,
0,
13,
39,
17,
28,
13,
4,
13,
17,
17,
4,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
13,
4,
18,
13,
13,
4,
13,
18,
13,
13,
2,
13,
17... | [
[
138,
2
],
[
138,
11
],
[
138,
12
],
[
138,
13
],
[
147,
15
],
[
135,
18
],
[
150,
22
],
[
27,
26
],
[
136,
33
],
[
136,
38
],
[
26,
40
],
[
26,
42
],
[
148,
43
... | [
"h,w,a,b = map(int,input().split())\n\nMOD = 1000000007\nfac = [1]\ninv = [1]\nfor i in range(1,200010):\n\tfac.append(fac[i-1]*i%MOD)\n\tinv.append(pow(fac[i],MOD-2,MOD))\n\nans = 0\n\nfor i in range(b+1,w+1):\n\tans += fac[h-a+i-2]*inv[h-a-1]*inv[i-1]*fac[a+w-i-1]*inv[a-1]*inv[w-i]%MOD\n\tans %= MOD\n\nprint(ans)... | h,w,a,b = map(int,input().split())
MOD = 1000000007
fac = [1]
inv = [1]
for i in range(1,200010):
fac.append(fac[i-1]*i%MOD)
inv.append(pow(fac[i],MOD-2,MOD))
ans = 0
for i in range(b+1,w+1):
ans += fac[h-a+i-2]*inv[h-a-1]*inv[i-1]*fac[a+w-i-1]*inv[a-1]*inv[w-i]%MOD
ans %= MOD
print(ans) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
17,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
... | [
[
236,
2
],
[
236,
11
],
[
236,
12
],
[
236,
13
],
[
224,
15
],
[
242,
22
],
[
233,
29
],
[
225,
34
],
[
212,
37
],
[
225,
42
],
[
46,
45
],
[
225,
50
],
[
56,
53
... | [
"h,w,a,b=map(int,input().split())\n\nU = 2*10**5\nMOD = 10**9+7\n \nfact = [1]*(U+1)\nfact_inv = [1]*(U+1)\n \nfor i in range(1,U+1):\n fact[i] = (fact[i-1]*i)%MOD\nfact_inv[U] = pow(fact[U],MOD-2,MOD)\n \nfor i in range(U,0,-1):\n\tfact_inv[i-1] = (fact_inv[i]*i)%MOD\n \ndef comb(n,k):\n if k < 0 or k > n:\n ... | h,w,a,b=map(int,input().split())
U = 2*10**5
MOD = 10**9+7
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
for i in range(1,U+1):
fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for i in range(U,0,-1):
fact_inv[i-1] = (fact_inv[i]*i)%MOD
def comb(n,k):
if k < 0 or k > n:
return 0
x = fact[n]
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
4,
13,
2,
13,
13,
2,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
2,
1... | [
[
259,
2
],
[
259,
11
],
[
259,
12
],
[
259,
13
],
[
241,
15
],
[
250,
18
],
[
260,
22
],
[
254,
23
],
[
230,
25
],
[
257,
26
],
[
217,
28
],
[
220,
35
],
[
230,
41... | [
"h, w, a, b = map(int, input().split())\nres = 0\nkai = min(w - b, h - a)\nmod = 10 ** 9 + 7\n\nkaijo = [0] * (h + w + 1)\nkaijo[0] = 1\nfor i in range(1, h + w + 1):\n kaijo[i] = (kaijo[i - 1] * i) % mod\ngyaku = [0] * (h + w + 1)\ngyaku[h + w] = pow(kaijo[h + w], mod - 2, mod)\nfor i in range(h + w, 0, -1):\n ... | h, w, a, b = map(int, input().split())
res = 0
kai = min(w - b, h - a)
mod = 10 ** 9 + 7
kaijo = [0] * (h + w + 1)
kaijo[0] = 1
for i in range(1, h + w + 1):
kaijo[i] = (kaijo[i - 1] * i) % mod
gyaku = [0] * (h + w + 1)
gyaku[h + w] = pow(kaijo[h + w], mod - 2, mod)
for i in range(h + w, 0, -1):
gyaku[i - 1] =... |
[
7,
6,
13,
12,
13,
0,
18,
13,
13,
39,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
18,
18,
13,
13,
13,
2,
2,
18,
18,
13,
13,
17,
13,
13,
0,
18,
13,
13,
39,
4,
13,
18,
18,
13,
13,
17,
2,
13,
17,
13,
28,
13,
18,
4,
13,
... | [
[
9,
6
],
[
83,
7
],
[
13,
12
],
[
85,
17
],
[
6,
21
],
[
83,
22
],
[
6,
28
],
[
83,
29
],
[
12,
32
],
[
87,
33
],
[
38,
35
],
[
83,
36
],
[
6,
42
],
[
83,
... | [
"class Factorial:\n def __init__(self,n,mod):\n self.f=[1]\n for i in range(1,n+1):\n self.f.append(self.f[-1]*i%mod)\n self.i=[pow(self.f[-1],mod-2,mod)]\n for i in range(1,n+1)[::-1]:\n self.i.append(self.i[-1]*i%mod)\n self.i.reverse()\n def factoria... | class Factorial:
def __init__(self,n,mod):
self.f=[1]
for i in range(1,n+1):
self.f.append(self.f[-1]*i%mod)
self.i=[pow(self.f[-1],mod-2,mod)]
for i in range(1,n+1)[::-1]:
self.i.append(self.i[-1]*i%mod)
self.i.reverse()
def factorial(self,i):
... |
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
13,
17,
0,
13,
2,
2,
13,
13,
17,
0,
13,
2,
2,
13,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
2,
13,
13... | [
[
4,
3
],
[
3,
12
],
[
274,
14
],
[
274,
16
],
[
274,
17
],
[
274,
18
],
[
253,
20
],
[
250,
27
],
[
269,
29
],
[
265,
32
],
[
275,
35
],
[
236,
36
],
[
259,
39
]... | [
"iH,iW,iA,iB = [int(x) for x in input().split()]\niD = 10**9+7 #法\n\niLBoxW=iB-1\niLBoxH=iH-iA-1\niRBoxW=iW-iB-1\niRBoxH=iH-1\n#iMax = iH+iW-2\niMax = max(iLBoxW+iLBoxH,iRBoxW+iRBoxH)\n\n#nCr = n!/r!(n-r)!\n\n#二分累乗法 iDを法として\ndef fBiPow(iX,iN,iD):\n iY = 1\n while iN > 0:\n if iN % 2 == 0:\n ... | iH,iW,iA,iB = [int(x) for x in input().split()]
iD = 10**9+7 #法
iLBoxW=iB-1
iLBoxH=iH-iA-1
iRBoxW=iW-iB-1
iRBoxH=iH-1
#iMax = iH+iW-2
iMax = max(iLBoxW+iLBoxH,iRBoxW+iRBoxH)
#nCr = n!/r!(n-r)!
#二分累乗法 iDを法として
def fBiPow(iX,iN,iD):
iY = 1
while iN > 0:
if iN % 2 == 0:
iX = iX * iX % iD
... |
[
7,
0,
13,
2,
2,
17,
17,
17,
41,
28,
13,
4,
13,
17,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
17,
4,
17,
0,
13,
13,
12,
13,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
0,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
13,
13,
0,
... | [
[
173,
2
],
[
11,
10
],
[
164,
17
],
[
22,
21
],
[
167,
28
],
[
34,
33
],
[
69,
39
],
[
71,
40
],
[
46,
43
],
[
165,
44
],
[
33,
45
],
[
165,
49
],
[
33,
51
],
... | [
"mod = 10 ** 9 + 7\nfac_table = [1 for i in range(200001)]\ninv_table = [1 for i in range(200001)]\n\n\ndef make_table(h, w):\n\n for i in range(1, h + w - 1):\n fac_table[i] = fac_table[i - 1] * i % mod\n inv_table[i] = pow(fac_table[i], mod - 2, mod)\n\n\ndef comb(n, r):\n return fac_table[n] ... | mod = 10 ** 9 + 7
fac_table = [1 for i in range(200001)]
inv_table = [1 for i in range(200001)]
def make_table(h, w):
for i in range(1, h + w - 1):
fac_table[i] = fac_table[i - 1] * i % mod
inv_table[i] = pow(fac_table[i], mod - 2, mod)
def comb(n, r):
return fac_table[n] * inv_table[n - r]... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17,
0,
13,
2,
39,
17,
2,
2,
13,
13,
17,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
0,
18,
13,
13,
2,
2... | [
[
182,
2
],
[
182,
11
],
[
182,
12
],
[
182,
13
],
[
188,
15
],
[
161,
22
],
[
183,
28
],
[
177,
29
],
[
164,
32
],
[
183,
38
],
[
177,
39
],
[
43,
42
],
[
183,
48
... | [
"H, W, A, B = map(int, input().split())\n\nmod = 10**9 + 7\n\nfact = [1] * (H + W - 1)\ninvfact = [1] * (H + W - 1)\n\nfor i in range(1, H + W - 1):\n fact[i] = fact[i - 1] * i % mod\nfor i in range(1, H + W - 1):\n invfact[i] = pow(fact[i], mod-2, mod)\n\ndef nCr(n,r):\n return fact[n] * invfact[r] * invf... | H, W, A, B = map(int, input().split())
mod = 10**9 + 7
fact = [1] * (H + W - 1)
invfact = [1] * (H + W - 1)
for i in range(1, H + W - 1):
fact[i] = fact[i - 1] * i % mod
for i in range(1, H + W - 1):
invfact[i] = pow(fact[i], mod-2, mod)
def nCr(n,r):
return fact[n] * invfact[r] * invfact[n-r]
result =... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
6,
13,
12,
13,
0,
18,
13,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
... | [
[
270,
2
],
[
270,
11
],
[
270,
12
],
[
270,
13
],
[
273,
15
],
[
29,
26
],
[
122,
27
],
[
124,
33
],
[
39,
36
],
[
122,
37
],
[
124,
43
],
[
47,
46
],
[
124,
51
... | [
"h, w, a, b = map(int, input().split())\n\nMOD = 10 ** 9 + 7\n\nclass ModCmb:\n def __init__(self, size):\n self.inv = [1] * (size + 1)\n self.fact = [1] * (size + 1)\n temp_inv = [1] * (size + 1)\n for i in range(2, size + 1):\n temp_inv[i] = ( -(MOD // i) * temp_inv[MOD%i... | h, w, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
class ModCmb:
def __init__(self, size):
self.inv = [1] * (size + 1)
self.fact = [1] * (size + 1)
temp_inv = [1] * (size + 1)
for i in range(2, size + 1):
temp_inv[i] = ( -(MOD // i) * temp_inv[MOD%i] ) % MOD
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
39,
17,
17,
0,
13,
17,
28,
13,
4,
13,
17,
4,
13,
13,
0,
18,
13,
13,
2,
2,
13,
13,
13,
0,
13,
2,
12,
13,
29,
2,
2,
2,
1... | [
[
170,
2
],
[
170,
11
],
[
170,
12
],
[
170,
13
],
[
173,
15
],
[
164,
22
],
[
161,
28
],
[
32,
31
],
[
165,
37
],
[
134,
39
],
[
165,
40
],
[
31,
41
],
[
162,
44
... | [
"H, W, A, B = map(int, input().split())\nmod = 10**9+7\n\nF = [1]*200010\np = 1\nfor i in range(1, len(F)):\n F[i] = p = p*i%mod\n\ndef comb(n, k):\n return F[n]*pow(F[n-k], mod-2, mod)*pow(F[k], mod-2, mod)%mod\n\nans = 0\nfor h in range(H-A):\n x = comb(B-1+h, h) # 右にB-1回、下にh回移動する方法の数\n y = comb(W+H-B-h-2, H-... | H, W, A, B = map(int, input().split())
mod = 10**9+7
F = [1]*200010
p = 1
for i in range(1, len(F)):
F[i] = p = p*i%mod
def comb(n, k):
return F[n]*pow(F[n-k], mod-2, mod)*pow(F[k], mod-2, mod)%mod
ans = 0
for h in range(H-A):
x = comb(B-1+h, h) # 右にB-1回、下にh回移動する方法の数
y = comb(W+H-B-h-2, H-h-1) # 右にW-B-1回、下にH... |
[
7,
6,
13,
12,
13,
0,
18,
13,
13,
2,
13,
17,
0,
18,
13,
13,
13,
0,
18,
13,
13,
2,
39,
17,
17,
2,
39,
17,
13,
0,
18,
13,
13,
2,
39,
17,
17,
2,
39,
17,
13,
0,
18,
13,
13,
2,
39,
17,
17,
2,
39,
17,
13,
28,
13,
... | [
[
9,
6
],
[
120,
7
],
[
122,
8
],
[
122,
10
],
[
16,
13
],
[
120,
14
],
[
125,
15
],
[
125,
16
],
[
21,
18
],
[
120,
19
],
[
122,
28
],
[
33,
30
],
[
120,
31
],
... | [
"class Combination:\n def __init__(self, size=100, mod=10**9 + 7):\n self.size = size + 2\n self.mod = mod\n self.fact = [1, 1] + [0] * size\n self.factInv = [1, 1] + [0] * size\n self.inv = [0, 1] + [0] * size\n\n for i in range(2, size + 2):\n self.fact[i] =... | class Combination:
def __init__(self, size=100, mod=10**9 + 7):
self.size = size + 2
self.mod = mod
self.fact = [1, 1] + [0] * size
self.factInv = [1, 1] + [0] * size
self.inv = [0, 1] + [0] * size
for i in range(2, size + 2):
self.fact[i] = self.fact[i -... |
[
7,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
2,
2,
40,
2,
13,
13,
18,
13,
2,
13,
13,
13,
29,
13,
23,
13... | [
[
236,
2
],
[
12,
11
],
[
55,
16
],
[
22,
19
],
[
11,
20
],
[
27,
24
],
[
11,
25
],
[
30,
29
],
[
55,
34
],
[
40,
37
],
[
11,
38
],
[
29,
39
],
[
237,
44
],
[
... | [
"Q = 10**9+7\ndef getInv(N):#Qはmod\n inv = [0] * (N + 1)\n inv[0] = 1\n inv[1] = 1\n for i in range(2, N + 1):\n inv[i] = (-(Q // i) * inv[Q%i]) % Q\n return inv\nmodfunctional = [1]*(2*10**5+1)\nmodinv = getInv(10**5+1)\nmodinvfunctional = [1]*(10**5+1)\nfor i in range(10**5):\n modinvfunc... | Q = 10**9+7
def getInv(N):#Qはmod
inv = [0] * (N + 1)
inv[0] = 1
inv[1] = 1
for i in range(2, N + 1):
inv[i] = (-(Q // i) * inv[Q%i]) % Q
return inv
modfunctional = [1]*(2*10**5+1)
modinv = getInv(10**5+1)
modinvfunctional = [1]*(10**5+1)
for i in range(10**5):
modinvfunctional[i+1] = (mo... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
4,
13,
17,
17,
17,
12,
13,
29,
4,
13,
13,
2,
13,
17,
13,
23,
13,
23,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
2,
2,
18,
13,
2,
13,
13,
18,
13... | [
[
182,
4
],
[
182,
13
],
[
182,
14
],
[
182,
15
],
[
164,
17
],
[
35,
29
],
[
37,
31
],
[
37,
33
],
[
35,
35
],
[
38,
37
],
[
47,
46
],
[
69,
52
],
[
71,
53
],
... | [
"import math\n\nh, w, a, b = map(int, input().split())\n\n#divmod\nmod = pow(10,9)+7\ndef divmod(num, mod=10**9+7):\n return pow(num, mod-2, mod)\n\n#combination\ndef comb(a,b):\n\tp=fact[a-b]*fact[b]%mod\n\treturn fact[a]*divmod(p)%mod\n\nfact = [1]\nfor i in range(1,h+w):\n fact.append(i*fact[i-1]%mod)\n#pr... | import math
h, w, a, b = map(int, input().split())
#divmod
mod = pow(10,9)+7
def divmod(num, mod=10**9+7):
return pow(num, mod-2, mod)
#combination
def comb(a,b):
p=fact[a-b]*fact[b]%mod
return fact[a]*divmod(p)%mod
fact = [1]
for i in range(1,h+w):
fact.append(i*fact[i-1]%mod)
#print(fact)
ans = 0
for j... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
28,
13,
4,
13,
17,
2,
2,
13,
13,
17,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,... | [
[
222,
2
],
[
222,
11
],
[
222,
12
],
[
222,
13
],
[
183,
15
],
[
213,
22
],
[
186,
27
],
[
204,
32
],
[
38,
37
],
[
193,
43
],
[
181,
44
],
[
214,
48
],
[
214,
53
... | [
"H, W, A, B = map(int,input().split())\nmod = 10**9+7\nC = [1,1]\ninv = [0,1]\nCinv = [1,1]\nfor i in range(2,H+W+1):\n C.append((C[-1]*i)%mod)\n inv.append((-inv[mod%i]*(mod//i)%mod))\n Cinv.append(Cinv[-1]*inv[-1]%mod)\nans = 0\nfor i in range(H-A):\n a = (C[i+B-1]*C[H-1-i+W-B-1])%mod\n a = (a*Cinv... | H, W, A, B = map(int,input().split())
mod = 10**9+7
C = [1,1]
inv = [0,1]
Cinv = [1,1]
for i in range(2,H+W+1):
C.append((C[-1]*i)%mod)
inv.append((-inv[mod%i]*(mod//i)%mod))
Cinv.append(Cinv[-1]*inv[-1]%mod)
ans = 0
for i in range(H-A):
a = (C[i+B-1]*C[H-1-i+W-B-1])%mod
a = (a*Cinv[B-1])%mod
a ... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
2,
13,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
1... | [
[
177,
2
],
[
177,
11
],
[
177,
12
],
[
177,
13
],
[
180,
15
],
[
162,
18
],
[
159,
25
],
[
175,
28
],
[
166,
29
],
[
168,
32
],
[
160,
37
],
[
153,
40
],
[
160,
45... | [
"H, W, A, B = map(int, input().split())\n\nans = 0 \nMOD = 10**9 + 7\nN = H + W - 2\nfac = [1] * (N+1)\ninv = [1] * (N+1)\n\n# 階乗\nfor i in range(1, N+1):\n fac[i] = i * fac[i - 1] % MOD\n \n# 普通の逆元テーブル\nfor i in range(1, N+1):\n inv[i] = pow(fac[i], MOD-2, MOD)\n \n \ndef f(x, y):\n ans = fac[x + y] * inv... | H, W, A, B = map(int, input().split())
ans = 0
MOD = 10**9 + 7
N = H + W - 2
fac = [1] * (N+1)
inv = [1] * (N+1)
# 階乗
for i in range(1, N+1):
fac[i] = i * fac[i - 1] % MOD
# 普通の逆元テーブル
for i in range(1, N+1):
inv[i] = pow(fac[i], MOD-2, MOD)
def f(x, y):
ans = fac[x + y] * inv[x] * inv[y] % MOD
... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
6,
13,
12,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
4,
18,
13,
13,
13,
0,
18,
13,
13,
4,
18,
13,
13,
13,
18,
13,
13,
23,
13,
23,
13,
23,
13,
2,
2,
17,
17,
17,
12,
13,
29,
2,... | [
[
310,
4
],
[
18,
15
],
[
41,
16
],
[
45,
17
],
[
45,
18
],
[
23,
20
],
[
41,
21
],
[
41,
25
],
[
43,
27
],
[
32,
29
],
[
41,
30
],
[
41,
34
],
[
43,
36
],
[
... | [
"import sys\ninput = sys.stdin.readline\n#str 注意\n\nclass Combination:\n def __init__(self, n_max, mod=10**9+7):\n self.mod = mod\n self.modinv = self.make_modinv_list(n_max)\n self.fac, self.facinv = self.make_factorial_list(n_max)\n\n def __call__(self, n, r):\n return self.fac[n... | import sys
input = sys.stdin.readline
#str 注意
class Combination:
def __init__(self, n_max, mod=10**9+7):
self.mod = mod
self.modinv = self.make_modinv_list(n_max)
self.fac, self.facinv = self.make_factorial_list(n_max)
def __call__(self, n, r):
return self.fac[n] * self.facinv[... |
[
7,
6,
13,
12,
13,
0,
18,
13,
13,
39,
17,
0,
18,
13,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
13,
13,
14,
2,
13,
13,
28,
13,
4,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
2,
2,
18,
18,
13,
13,
17,
2,
13,
17,
18,
13,
... | [
[
9,
6
],
[
108,
7
],
[
15,
12
],
[
108,
13
],
[
110,
19
],
[
25,
22
],
[
108,
23
],
[
115,
24
],
[
115,
25
],
[
110,
28
],
[
115,
29
],
[
32,
31
],
[
110,
35
],
... | [
"class mod_comb_k():\n def __init__(self, MAX_N = 10**6, mod = 10**9+7):\n self.fact = [1]\n self.fact_inv = [0] * (MAX_N + 4)\n self.mod = mod\n if MAX_N > mod:print('MAX_N > mod !')\n for i in range(MAX_N + 3):\n self.fact.append(self.fact[-1] * (i + 1) % self.mod)\n self.fact_inv[-1] = po... | class mod_comb_k():
def __init__(self, MAX_N = 10**6, mod = 10**9+7):
self.fact = [1]
self.fact_inv = [0] * (MAX_N + 4)
self.mod = mod
if MAX_N > mod:print('MAX_N > mod !')
for i in range(MAX_N + 3):
self.fact.append(self.fact[-1] * (i + 1) % self.mod)
self.fact_inv[-1] = pow(self.fact[-... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
2,
2,
17,
17,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
1... | [
[
230,
2
],
[
230,
11
],
[
230,
12
],
[
230,
13
],
[
191,
15
],
[
221,
22
],
[
194,
31
],
[
222,
36
],
[
233,
39
],
[
222,
44
],
[
197,
47
],
[
51,
50
],
[
222,
55
... | [
"h,w,a,b = map(int, input().split())\n\nmod = 10**9 + 7\nn = 10**5 * 2 + 1\n\nfact = [1]*(n+1)\nrfact = [1]*(n+1)\nr = 1\nfor i in range(1, n+1):\n fact[i] = r = r * i % mod\nrfact[n] = r = pow(fact[n], mod-2, mod)\nfor i in range(n, 0, -1):\n rfact[i-1] = r = r * i % mod\n\n# nPk (mod MOD) を求める\ndef perm(n, k):\... | h,w,a,b = map(int, input().split())
mod = 10**9 + 7
n = 10**5 * 2 + 1
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
rfact[i-1] = r = r * i % mod
# nPk (mod MOD) を求める
def perm(n, k):
return fact[n] * r... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
2,
2,
13,
2,
13,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
12,
13,
14,
2... | [
[
252,
2
],
[
252,
15
],
[
252,
16
],
[
252,
17
],
[
258,
19
],
[
29,
28
],
[
32,
31
],
[
49,
34
],
[
37,
36
],
[
28,
39
],
[
36,
39
],
[
47,
41
],
[
31,
42
],
... | [
"H, W, A, B = map(int, open(0).read().split())\nMOD = 10**9+7\n\ndef modperm(m, n, mod):\n p = 1\n for i in range(n):\n p = p * (m - i) % mod\n return p\n\ndef modcomb(m, n, mod):\n if n > m - n:\n n = m - n\n p = modperm(m, n, mod)\n q = pow(modperm(n, n, mod), mod - 2, mod)\n re... | H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7
def modperm(m, n, mod):
p = 1
for i in range(n):
p = p * (m - i) % mod
return p
def modcomb(m, n, mod):
if n > m - n:
n = m - n
p = modperm(m, n, mod)
q = pow(modperm(n, n, mod), mod - 2, mod)
return p * q % mod
t... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
2,
13,
13,
17,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
13,
4,
13,
13,
14,
2,
13,
17,
0,
18,
13,
13,
2,
2,
... | [
[
318,
4
],
[
318,
13
],
[
318,
14
],
[
318,
15
],
[
294,
17
],
[
261,
24
],
[
319,
27
],
[
283,
28
],
[
33,
32
],
[
262,
35
],
[
285,
39
],
[
43,
42
],
[
262,
45
... | [
"#D問題\nimport math\nH,W,A,B = map(int,input().split())\nmod = 10**9 + 7\n\nM = H+W-1\nfact = [1 for i in range(M)]\nfor i in range(M):\n if i == 0:\n pass\n else:\n fact[i] = (fact[i-1]*i)%mod\n \nrefact = [1 for i in range(M)]\nm = mod-2\nb = bin(m)\nb = b.lstrip(\"0b\")\nb = b[::-1]\nm2... | #D問題
import math
H,W,A,B = map(int,input().split())
mod = 10**9 + 7
M = H+W-1
fact = [1 for i in range(M)]
for i in range(M):
if i == 0:
pass
else:
fact[i] = (fact[i-1]*i)%mod
refact = [1 for i in range(M)]
m = mod-2
b = bin(m)
b = b.lstrip("0b")
b = b[::-1]
m2 = len(b)
for i in range(... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13... | [
[
237,
2
],
[
237,
13
],
[
237,
14
],
[
237,
15
],
[
55,
21
],
[
53,
24
],
[
55,
25
],
[
30,
29
],
[
55,
32
],
[
53,
34
],
[
55,
35
],
[
53,
42
],
[
29,
45
],
[... | [
"\na,b,c,d = list(map(int, input().split()))\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\np = 10**9+7\nN = 10 ** 6 + 2\nfact = [1, 1] # fact[n] = (n! mod p)\nfactinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)\ninv =... |
a,b,c,d = list(map(int, input().split()))
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 ** 6 + 2
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1] # factinv... |
[
7,
15,
13,
12,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
42,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
13,
13,
13,
0,
13,
13,
14,
2,
13,
17,
0,
13,
13,
29,
13,
23,
13,
2... | [
[
7,
6
],
[
56,
7
],
[
10,
9
],
[
13,
12
],
[
18,
17
],
[
54,
19
],
[
27,
19
],
[
22,
19
],
[
6,
20
],
[
29,
20
],
[
23,
22
],
[
17,
24
],
[
6,
25
],
[
29,
... | [
"import math\n\ndef modinv(a,m):\n\tb = m\n\tu = 1\n\tv = 0\n\twhile(b):\n\t\tt = a // b\n\t\ta -= t * b\n\t\ta,b = b,a\n\t\tu -= t * v\n\t\tu,v = v,u\n\tu %= m\n\tif u < 0:\n\t\tu += m\n\treturn u\n\ninp = input().split(' ')\ninpint = [int(i) for i in inp]\nh = inpint[0]\nw = inpint[1]\na = inpint[2]\nb = inpint[3... | import math
def modinv(a,m):
b = m
u = 1
v = 0
while(b):
t = a // b
a -= t * b
a,b = b,a
u -= t * v
u,v = v,u
u %= m
if u < 0:
u += m
return u
inp = input().split(' ')
inpint = [int(i) for i in inp]
h = inpint[0]
w = inpint[1]
a = inpint[2]
b = inpint[3]
xfac = [0 for r in range(h+w-2)]
xfac_inv =... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
17,
42,
13,
14,
2,
13,
17,
0,
13,
2,
2,
13,
13,
13,
0,
13,
2,
2,
13,
13,
13,
0,
13,
17,
29,
13,
23,
13,
23,
13,
0,
... | [
[
249,
2
],
[
249,
11
],
[
249,
12
],
[
249,
13
],
[
234,
15
],
[
25,
24
],
[
54,
30
],
[
47,
30
],
[
34,
33
],
[
24,
36
],
[
33,
36
],
[
52,
37
],
[
40,
37
],
... | [
"H, W, A, B = map(int, input().split())\n\nMOD = 10 ** 9 + 7\n\n\ndef pow_mod(x, p):\n res = 1\n while p:\n if p % 2:\n res = res * x % MOD\n x = x * x % MOD\n p //= 2\n return res\n\n\nF = [1]\ninvF = []\n\n\ndef comb_mod(n, r):\n return F[n] * invF[r] * invF[n - r] % MO... | H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
def pow_mod(x, p):
res = 1
while p:
if p % 2:
res = res * x % MOD
x = x * x % MOD
p //= 2
return res
F = [1]
invF = []
def comb_mod(n, r):
return F[n] * invF[r] * invF[n - r] % MOD
for i in range(1, H +... |
[
7,
12,
13,
12,
13,
14,
2,
2,
13,
17,
2,
13,
13,
29,
17,
0,
13,
4,
13,
13,
2,
13,
13,
29,
2,
2,
2,
18,
13,
13,
18,
13,
13,
18,
13,
2,
13,
13,
13,
23,
13,
23,
13,
23,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17... | [
[
42,
8
],
[
42,
11
],
[
40,
12
],
[
17,
16
],
[
42,
19
],
[
40,
21
],
[
42,
22
],
[
40,
29
],
[
16,
32
],
[
42,
32
],
[
40,
36
],
[
16,
37
],
[
42,
37
],
[
... | [
"def main():\n def cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n mod = 10**9+7 # 出力の制限\n N = 10**6\n g1 = [1, 1] # 元テーブル\n g2 = [1, 1] # 逆元テーブル\n inverse = [0, 1] # 逆元テーブル計算用テーブル\n\n for i in ra... | def main():
def cmb(n, r, mod):
if (r < 0 or r > n):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 # 出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.