submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s148335538
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) shiharai=N l = [int(x) for x in list(str(N))] for i in range(l): while l[i] in D: shiharai+=1 l = [int(x) for x in list(str(shiharai))] print(shiharai)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s867128631
p04045
Runtime Error
input_array = list(map(int,input().split())) N = input_array[0] input_array = list(map(int,input().split())) num = [1,1,1,1,1,1,1,1,1,1] ok = [] out = [] for l in range(len(input_array)): num[input_array[l]] = 0 for i in range(len(num)): if num[i] == 1: ok.append(i) N = list(str(N)) for n in N: ...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s119533351
p04045
Runtime Error
li_1 = list(map(int,input().split())) N = li_1[0] K = li_1[1] D = list(map(int,input().split())) minvalue=N temp=0 for i in range(10*N): i=i+N numtemp=i num_4=int(i/10000) i=i-10000*num_4 num_3=int(i/1000) i=i-1000*num_3 num_2=int(i/100) i=i-100*num_2 num_1=int(i/10) i=i-10*n...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s074228576
p04045
Runtime Error
li_1 = list(map(int,input().split())) N = li_1[0] K = li_1[1] D = list(map(int,input().split())) minvalue=N temp=0 for i in range(10*(N+1)): i=i+N numtemp=i num_4=int(i/10000) i=i-10000*num_4 num_3=int(i/1000) i=i-1000*num_3 num_2=int(i/100) i=i-100*num_2 num_1=int(i/10) i=i-...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s511504712
p04045
Runtime Error
li_1 = list(map(int,input().split())) N = li_1[0] K = li_1[1] D = list(map(int,input().split())) minvalue=N temp=0 for i in range(N+1): i=i+N numtemp=i num_4=int(i/10000) i=i-10000*num_4 num_3=int(i/1000) i=i-1000*num_3 num_2=int(i/100) i=i-100*num_2 num_1=int(i/10) i=i-10*n...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s342694197
p04045
Runtime Error
n,k=map(int,input().split()) d=list(input().split()) for i in range(n,100001): set_i=set(list(str(i))) for j in set_i: if s in d: break else: print(i) break
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s979709031
p04045
Runtime Error
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """042-c""" import sys ZERO_UNICODE = 48 def solve(dislike_digits_table, first_like_digit, number): """Solve.""" if dislike_digits_table[int(number[0])]: while dislike_digits_table[int(number[0])]: number = "{0}{1}".format(chr(ord(number[0]...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s994011015
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) L = [i for i in range(10) if i not in D] A = [] for i in L: A.append(i) for i in L: for j in L: A.append(10*i+j) for i in L: for j in L: for k in L: A.append(100*i+10*j+k) for i in L: for j in L: for k in L: for l in L...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s565426486
p04045
Runtime Error
n, k = map(int, input().split()) dislikes = list(map(int, input().split()) m = n while True: m = list(str(m)) l = [] for p in m: if int(p) not in dislikes: l.append(p) continue else: m = int(''.join(m))+1 break if len(l) >= len(str(n)): ...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s231547753
p04045
Runtime Error
N, K = [int(i) for i in input().split()] ds = [int(i) for i in input().split()] #N, K = (99999, 8) #ds = [0,1,2,3,4,5,6,7,9] def run_code(N, K, ds): dislike_digits_set = set(i for i in ds) avail_digits = [i for i in range(10) if i not in dislike_digits_set] avail_min = avail_digits[0] def get_next_d...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s219891551
p04045
Runtime Error
N, K = [int(i) for i in input().split()] ds = [int(i) for i in input().split()] #N, K = (99999, 1) #ds = [0] def run_code(N, K, ds): dislike_digits_set = set(i for i in ds) avail_digits = [i for i in range(10) if i not in dislike_digits_set] avail_min = avail_digits[0] def get_next_digit(d): ...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s837836376
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) n = str(N) ans = N for i in reversed(range(str(len(N)))): temp = n[i] while(int(temp) in D): ans += 1 print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s762676909
p04045
Runtime Error
N, K = map(int, input().split()) D = list(map(int, input().split())) n = str(N) ans = N for i in reversed(range(N)): temp = n[i] while(int(temp) in D): ans += 1 print(ans)
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s815140573
p04045
Runtime Error
n, k = [int(i) for i in input().split()] q = n not_liked = [int(i) for i in input().split()] liked = [i for i in range(10) if i not in not_liked] digits = list() while(n): digits.append(n%10) n //= 10 digits.reverse() ind = -2 for i in digits: if i not in liked: ind = digits.index(i) break js = list(...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s806999533
p04045
Runtime Error
n, k = [int(i) for i in input().split()] q = n not_liked = [int(i) for i in input().split()] liked = [i for i in range(10) if i not in not_liked] digits = list() while(n): digits.append(n%10) n //= 10 digits.reverse() ind = -2 for i in digits: if i not in liked: ind = digits.index(i) break js = list(...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s929331940
p04045
Runtime Error
n, k = [int(i) for i in input().strip(" ").split()] q = n not_liked = [int(i) for i in input().strip(" ").split()] liked = [i for i in range(10) if i not in not_liked] digits = list() while(n): digits.append(n%10) n //= 10 digits.reverse() ind = -2 for i in digits: if i not in liked: ind = digits.index(i) ...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s402522954
p04045
Runtime Error
n, k = [int(i) for i in input().strip(" ").split()] q = n not_liked = [int(i) for i in input().strip(" ").split()] liked = [i for i in range(10) if i not in not_liked] digits = list() while(n): digits.append(n%10) n //= 10 digits.reverse() ind = -2 for i in digits: if i not in liked: ind = digits.index(i) ...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s839492722
p04045
Runtime Error
N, K = raw_input().split() D = raw_input().split() candi = [str(i) for i in xrange(10)] for d in D: candi.remove(d) def decide(i): if i >= len(N): return '' for c in candi: if N[i] == c: return c + decide(i+1) elif N[i] < c: return c + candi[0] * (len(N) - i ...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s036894632
p04045
Runtime Error
import itertools if __name__ == "__main__": line_one = input().split() line_two = input().split() use_num = {'0','1','2','3','4','5','6','7','8','9'}.difference(line_two) all_comb = list(itertools.product(use_num, repeat=len(str(line_one[0])))) nums = list((map(int,["".join(x) for x in all_comb]))...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s447764636
p04045
Runtime Error
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> int main() { int n, k, d; bool is_safe[10] = {}; std::cin >> n >> k; std::fill(is_safe, is_safe + 10, true); for (int ki = 0 ; ki < k; ++ki) { std::cin >> d; is_safe[d] = false; } wh...
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s006728586
p04045
Runtime Error
n, k = map(int, raw_input().split()) d = map(int, raw_input().split()) def use_d(n): for i in list(str(n)): if int(i) in d: return True else: return False while n < 100000: if use_d(n): n += 1 else: print n sys.exit()
1000 8 1 3 4 5 6 7 8 9
2000
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha is very particular about numbers. There are <var>K</var> digits that she dislikes: <var>D_1, D_2, ..., D_K</var>.</p> <p>She is shopping, and now paying at the cashier. Her total is <var>N</var> y...
s225904543
p04046
Wrong Answer
MODD = 10**9 + 7 fac=[1]*200001 aaa=1 for i in range(1,200001): aaa=(aaa*i)%MODD fac[i]=aaa import math as m def perm(x,y,z) -> int: #print(fac[x]//(fac[y]*fac[z])) return (fac[x]//(fac[y]*fac[z])) h,w,a,b= [int(x) for x in input().split()] A = h-a B = b-1 C = h-1 D = w-b-1 j=0 k=B kl = C jl = D...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s495465771
p04046
Wrong Answer
H, W, A, B = map(int,input().split()) G = [[0]*W for _ in range(H)] MOD = 10**9+7 for i in range(W): G[0][i] = 1 for i in range(H): G[i][0] = 1 for i in range(H-A, H): for j in range(B): G[i][j] = -float('inf') for i in range(1, H): for j in range(1, W): a = max(G[i-1][j], 0) b = max(G[i][j-1], 0...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s573780847
p04046
Wrong Answer
H, W, A, B = map(int,input().split()) G = [[0]*W for _ in range(H)] for i in range(W): G[0][i] = 1 for i in range(H): G[i][0] = 1 for i in range(H-A, H): for j in range(B): G[i][j] = -float('inf') for i in range(1, H): for j in range(1, W): a = max(G[i-1][j], 0) b = max(G[i][j-1], 0) G[i][j]+...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s092440387
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) from math import factorial mod = 1000000007 Fact = [1] compro = 1 for i in range(1,H+W): compro *= i compro %= mod Fact.append(compro) ans = 0 for i in range(B,W): ans += Fact[H-A-1+i]/Fact[H-A-1]/Fact[i] * Fact[A-1+W-1-i]/Fact[A-1]/Fact[W-1-i] ans %= mod pri...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s006471739
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) from math import factorial mod = 1000000007 Fact = [factorial(x)%mod for x in range(H+W)] ans = 0 for i in range(B,W): ans += Fact[H-A-1+i]/Fact[H-A-1]/Fact[i] * Fact[A-1+W-1-i]/Fact[A-1]/Fact[W-1-i] print(int(ans%mod))
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s804059412
p04046
Wrong Answer
H, W, A, B = map(int, open(0).read().split()) MOD = 10**9+7 factorials = [1] * (H + W + 1) inv_factorials = [1] * (H + W + 1) for i in range(H + W): factorials[i+1] = factorials[i] * (i + 1) % MOD inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials)) def modcomb(m, n, mod): return factorial...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s652561515
p04046
Wrong Answer
# -*- coding: utf-8 -*- from scipy.special import comb def main(): H, W, A, B = map(int, input().split()) whole = 0 part = 0 H = H - 1 W = W - 1 A = A - 1 B = B - 1 whole = comb((H + W), H, exact=True) part = comb((A + B), A, exact=True) ans = whole - part print(...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s766222763
p04046
Wrong Answer
# -*- coding: utf-8 -*- # D - いろはちゃんとマス目 from scipy.special import comb H, W, A, B = map(int, input().split()) whole = 0 part = 0 whole = comb((H + W) - 2, H - 1, exact=True) part = comb((A + B), A, exact=True) ans = whole - part print(ans)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s374575742
p04046
Wrong Answer
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 for i in range(h-a): ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s790602502
p04046
Wrong Answer
h,w,a,b=map(int,input().split()) p=10**9+7 #p=127 def modp_factorial(n): s=1 for x in range(1,h+1): s=(s*x) % p return s def modp_prod(lst): s=1 for x in lst: s=(s*x)%p return s def inv(n): s=1 q=p-2 while q>0: if q&1: s=s*n % p n=n*n % p...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s657351710
p04046
Wrong Answer
from scipy.special import comb H, W, A, B = map(int, input().split()) ans = 0 for i in range(W - B+1): ans += comb(H - A + B + i, H-A, exact=True) * \ comb(W - B + A - i, A, exact=True) ans = int(ans % (10**9+7)) print(ans)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s642889501
p04046
Wrong Answer
from math import factorial H,W,A,B = map(int,input().split()) rt = 0 for i in range(H-A): rt += (factorial(i+B-1) * factorial(H-i+W-B-2)) // (factorial(i) * factorial(B-1) * factorial(H-i-1) * factorial(W-B-1)) print(rt % 100000007)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s260135513
p04046
Wrong Answer
from math import factorial H,W,A,B = map(int,input().split()) rt = 1 for i in range(H-A-1): rt += (factorial(i+B) * factorial(H-i+W-B)) // (factorial(i+1) * factorial(B) * factorial(H-i) * factorial(W-B)) print(rt) print(rt % 100000007)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s431428133
p04046
Wrong Answer
import sys import numpy as np import random from decimal import Decimal import itertools import re import bisect from collections import deque, Counter from functools import lru_cache sys.setrecursionlimit(10**9) INF = 10**13 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys....
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s459479103
p04046
Wrong Answer
def frac(n): m=1 for i in range(1, n+1): m = m * i % 1000000007 return m % 1000000007 (h,w,a,b)=[int(x) for x in input().split()] ans=0 for i in range(1,w-b+1): ans+=(((frac(h-a-1+w-i)/(frac(h-a-1)*frac(w-i)))%1000000007)*((frac(a-1+i-1)/(frac(a-1)*frac(i-1)))%1000000007))%1000000007 print(int(ans))
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s003447190
p04046
Wrong Answer
h,w,a,b=map(int, input().split())
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s342887210
p04046
Wrong Answer
from math import factorial h,w,a,b=map(int,input().split()) res=0 fact=[] for i in range(h+w): fact.append(factorial(i)) for i in range(b+1,w+1): first=fact[i+h-a-2]//(fact[i-1]*fact[h-a-1]) second=fact[w-i+a-1]//(fact[w-i]*fact[a-1]) res+=first*second print(res)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s699199104
p04046
Wrong Answer
def conbi(n, r): bunbo = 1 bunshi = 1 if n / 2 < r: r = n - r while r > 0: bunbo *= r bunshi *= n r -= 1 n -= 1 return bunshi // bunbo def conbi_mod(n, r): return conbi(n, r) % (10 ** 9 + 7) H, W, A, B = map(int, input().split()) if B < W / 2: ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s227611326
p04046
Wrong Answer
def conbi(n, r): bunbo = 1 bunshi = 1 if n / 2 < r: r = n - r while r > 0: bunbo *= r bunshi *= n r -= 1 n -= 1 return bunshi // bunbo def conbi_mod(n, r): return conbi(n, r) % (10 ** 9 + 7) H, W, A, B = map(int, input().split()) if B < W / 2: ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s073687667
p04046
Wrong Answer
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, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s319353649
p04046
Wrong Answer
h,w,a,b = map(int,input().split()) MOD = 10**9 + 7 def comb(n,r): res = 1 fac = 1 for i in range(r): res *= n-i res %= MOD fac *= i+1 fac %= MOD return res*pow(fac,MOD-2,MOD)%MOD cnt = 0 for i in range(w-b+1): cnt += comb(h-a-1+b+i,h-a-1) * comb(w-b-i-1+a-1,a-1) ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s073445048
p04046
Wrong Answer
from scipy.misc import comb h, w, a, b = (int(x) for x in input().split()) ans = 0 for j in range(b, w): ans += comb(h-a-1 + j, j, exact=True) * comb(a+w-2 - j, w-1 - j, exact=True) ans %= 100000007 print(ans)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s737649009
p04046
Wrong Answer
import math def conbination(m, n): return math.factorial(m) // (math.factorial(m-n) * math.factorial(n)) h, w, a, b = (int(x) for x in input().split()) ans = 0 for j in range(b, w): ans += conbination(h - a + j - 1, j) * conbination(a + w - j - 2, w - j - 1) ans %= 100000007 print(ans)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s683424295
p04046
Wrong Answer
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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s442574676
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) total = 0 tmp1, tmp2 = 1, 1 # 初期化 tmp3, tmp4 = 1, 1 # 初期化 for i in range(B,W,1): conv1, conv2 = 0, 0 # 初期化 if i == B: for j in range(i): tmp1 *= i+(H-A-1)-j tmp1 %= (10**9+7) for j in range(i, 0, -1): tmp2 *= j tmp2 %= (10**9+7) else: tmp1 ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s682169581
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) # 全組み合わせ数 total = 1 min_num = min(H-1, W-1) for i in range(min_num): total *= (H+W-2)-i total %= (10**9+7) tmp = 1 for i in range(min_num, 0, -1): tmp *= i tmp %= (10**9+7) total /= tmp #print(int(total)) # 除外する組み合わせ数 remove_num = 0 if A == 1: remove_num = 1 else: if B =...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s666634370
p04046
Wrong Answer
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 + ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s768234672
p04046
Wrong Answer
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]...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s742427691
p04046
Wrong Answer
h, w, a, b = map(int, input().split()) f = [[0 for i in range(w)] for j in range(h)] for i in range(w): f[0][i] = 1 for i in range(h-a): f[i][0] = 1 for i in range(1, h): for j in range(1, w): if not (i >= h-a and j <= b-1): f[i][j] = f[i-1][j] + f[i][j-1] print(f[h-1][w-1])
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s867173209
p04046
Wrong Answer
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): ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s221157131
p04046
Wrong Answer
H,W,A,B = map(int,input().split()) class Combination: """ O(n)の前計算を1回行うことで,O(1)でnCr mod mを求められる n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms) 使用例: comb = Combination(1000000) print(comb(5, 3)) # 10 """ def __init__(self, n_max, mod=10 ** 9 + 7): self.mod = mod self.mod...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s144912752
p04046
Wrong Answer
h,w,a,b = map(int,input().split()) dp = [[0 for i in range(h+1)] for j in range(w+1)] for i in range(w): for j in range(h): dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j] if i == 0 and j == 0: dp[i+1][j+1] = 1 if i < b and j >= h-a: dp[i+1][j+1] = 0 print(dp[w][h])
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s882975058
p04046
Wrong Answer
from sys import stdin from operator import itemgetter import math # stdin = open("sample.txt") H,W,A,B = [int(x) for x in stdin.readline().rstrip().split()] path_list = list(range(W-B)) path_list2 = list(range(0)) path_list.reverse() for path in path_list: path_list2.append(math.factorial((W-path-1)+(H-A-1))//mat...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s421388698
p04046
Wrong Answer
h,w,a,b = map(int, input().split()) def modinv(a, mod=10**9+7): return pow(a, mod-2, mod) def comb(n, r, mod=10**9+7): r = min(r, n-r) res = 1 for i in range(r): res = res * (n - i) * modinv(i+1, mod) % mod return res ans=0 for i in range(h-a): pre=comb(i+b-1,i) post=comb(h+w-b-2-...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s583800768
p04046
Wrong Answer
def f(x): if x==0: return 1 else: fac=1 for i in range(1,x+1): fac*=i return fac def c(x,y): return f(x+y)//(f(x)*f(y)) h,w,a,b=map(int,input().split()) ans=0 ans+=c((h-a-1),(b))*c((a),(w-b-1)) for i in range(h-a-1): ans+=c(i,b)*c(h-i-1,w-b-2) print(ans)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s703950396
p04046
Wrong Answer
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=m...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s481182268
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) import math def f(n): a1 = pow(math.factorial(B + n + H - A - 1), 1, 10**9+7) a2 = pow(math.factorial(W - B - 1 - n + A - 1), 1, 10**9+7) b1 = pow(math.factorial(B + n) % (10**9 + 7), 1, 10**9+7) b2 = pow(math.factorial(H - A - 1) % (10**9 + 7), 1, 10**9+7) b3 = pow(ma...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s361316546
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) import math def f(n): a1 = math.factorial(B + n + H - A - 1) % (10**9 + 7) a2 = math.factorial(W - B - 1 - n + A - 1) % (10**9 + 7) b1 = math.factorial(B + n) % (10**9 + 7) b2 = math.factorial(H - A - 1) % (10**9 + 7) b3 = math.factorial(W - B - 1 - n) % (10**9 + 7) ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s060932146
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) import math def f(n): a1 = math.factorial(B + n + H - A - 1) % (10**9 + 7) a2 = math.factorial(W - B - 1 - n + A - 1) % (10**9 + 7) b1 = math.factorial(B + n) % (10**9 + 7) b2 = math.factorial(H - A - 1) % (10**9 + 7) b3 = math.factorial(W - B - 1 - n) % (10**9 + 7) ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s770688043
p04046
Wrong Answer
h,w,a,b=map(int,input().split()) mod=10**9+7 ans=0 def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = h+w+1 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s406739000
p04046
Wrong Answer
from scipy.misc import comb H,W,A,B=map(int,input().split()) p=0 for i in range(B+1,W+1): p+=comb(H-A+i,i,exact=True)*comb(W-i+1+A,A,exact=True) k=p%1000000007 print(k)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s393093312
p04046
Wrong Answer
# 0<=y<h-bなるyを通るとこからゴールの右下までのnCrをする # グリッドじゃなくてマス目にしただけでnCrわからなくなるの、あたまが弱すぎる h, w, a, b = map(int, input().split()) ans = 0 def ncr(n, r): res = 1 for i in range(1, r + 1): res = res * (n - i + 1) // i return res print(ncr(h + w, h)) for y in range(1, h - b + 1): ans += ncr(y, a) * ncr(w - ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s989878011
p04046
Wrong Answer
import fractions H,W,A,B=map(int,input().split()) mod =10**9+7 def C(n,m): if n*m==0: C =1 else: bunbo=[0]*min(m,n) bunsi=[0]*min(m,n) for k in range(min(m,n)): bunbo[k]=min(m,n)-k bunsi[k]=n+m-k for k in range(min(m,n)): for j in rang...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s465912181
p04046
Wrong Answer
H,W,A,B=map(int,input().split()) def kumi(h,w,a): a[0]=1 #print(a) for i in range(1,h): a[i]=a[i-1]*(i-1+w)//i%(10**9+7) #print(a) return a f=[0]*(H-A) s=[0]*(H) f=kumi(H-A,B,f) s=kumi(H,W-B,s) #print(f) #print(s) ans=0 for i in range(H-A): ans+=f[i]*s[-i-1] print(ans%(10**9+7))
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s176266581
p04046
Wrong Answer
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) ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s840987147
p04046
Wrong Answer
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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s251441257
p04046
Wrong Answer
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) s = time.time() 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...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s023032841
p04046
Wrong Answer
# # import numpy as np # # import math # # import sys # # sys.float_info.max # # H, W, A, B = map(int, input().split()) # # StoB = np.zeros(B) # # BtoE = np.zeros(B) # # sum = 0 # # all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # # all = all % (10 ** 9 + 7) # # for i in range(B): # #...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s901014310
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) mod=10**9+7 N=H+W+1 bikkuri=[0 for i in range(N)] bikkuri[0]=1 for i in range(1,N): bikkuri[i] = (i * bikkuri[i-1])%mod gyaku=[0 for i in range(N)] gyaku[0]=1 for i in range(1, N): gyaku[i]=pow(bikkuri[i], mod-2, mod) def comb(n,r): return bikkuri[n]*gyaku[n-r]*gyaku[r...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s359316458
p04046
Wrong Answer
H, W, A, B = list(map(int, input().split())) bikkuri=[1] mod = 10**9 + 7 for i in range(1, H+W): bikkuri.append((i * bikkuri[i-1])%mod) def comb(n, r): return round(bikkuri[n] / (bikkuri[n-r] * bikkuri[r])) dame = [] for i in range(B): dame.append(comb(H-A-1+i, i)%mod * comb(W-1-i+A-1,A-1)%mod) ans = co...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s632648545
p04046
Wrong Answer
def nCr(n, r): r = min(r, n - r) if r == 0: return 1; if r == 1: return n; numerator = [n - r + i + 1 for i in range(r)] denominator = [i + 1 for i in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s916458393
p04046
Wrong Answer
h,w,a,b=map(int,input().split()) ans = 0 mod = 10**9 + 7 flist = [1] * (h+w+1) for i in range(1,h+w): flist[i] = (flist[i-1] * i)%mod def cmb(n,r): return (flist[n]//(flist[r]*flist[n-r]))%mod for x in range(b,w): c = x + (h - a - 1) d = (w - x - 1) + (a - 1) e = cmb(c, x) * cmb(d, a - 1) ans...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s131458036
p04046
Wrong Answer
h,w,a,b=map(int,input().split()) ans = 0 mod = 10**9 + 7 flist = [1] * (h+w+1) for i in range(1,h+w): flist[i] = (flist[i-1] * i)%mod def cmb(n,r): return (flist[n]//(flist[r]*flist[n-r]))%mod for x in range(b,w): c = x + (h - a - 1) d = (w - x - 1) + (a - 1) e = cmb(c, x) * cmb(d, a - 1) ans...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s173552247
p04046
Wrong Answer
h,w,a,b=map(int,input().split()) ans = 0 flist = [1 for _ in range(h+w)] for i in range(1,h+w): flist[i] = flist[i-1] * i def cmb(n,r): return flist[n]//(flist[r]*flist[n-r]) for x in range(b,w): c = x + (h - a - 1) d = (w - x - 1) + (a - 1) e = cmb(c, x) * cmb(d, a - 1) ans += e print(ans)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s291255669
p04046
Wrong Answer
import math def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n - r)) h, w, a, b = list(map(int, input().split())) ans = 0 for i in range(w-b): if (i == 0): ans += comb(h-a-1+b+i, b+i) * comb(a+w-1-b-i, a) else: ans += (comb(h-a-1+b+i, b+i) - comb(h-a-1+b+i-...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s578227835
p04046
Wrong Answer
from operator import mul from functools import reduce def cmb(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1,r + 1)) return over // under nums = input().split() H = int(nums[0]) W = int(nums[1]) A = int(nums[2]) B = int(nums[3]) MX = ma...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s338908529
p04046
Wrong Answer
def comb(n,k,p): from math import factorial if n<0 or k<0 or n<k: return 0 if n==0 or k==0: return 1 a=factorial(n)%p b=factorial(k)%p c=factorial(n-k)%p return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p def power_func(a,b,p): if b==0: return 1 if b%2==0: d=power_func(a,b//2,p) return d*d %...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s784839087
p04046
Wrong Answer
base = 10**9 + 7 def comb(x, y):#xCy = [x-1]C[y-1] * n / k res = 1 for i in range(x): res = res * (x-i) for i in range(y): res = res // (y-i) return res % base H, W, A, B = map(int, input().split()) res = 0 for i in range(W-B): res += comb(H-A-1 + W-i-1, W-i-1)*comb(A-1+i,i) res %= base print(res...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s371150274
p04046
Wrong Answer
base = 10 ** 9 + 7 res = 0 H, W, A, B = map(int, input().split()) f1 = [1 for i in range(W)] for i in range(H-1): #f1 -> #f2 f2 = [0 for j in range(W)] for j in range(W): if j == 0: f2[0] = f1[0] elif i > H-1-A and j<B: f2[j] = f1[j] else: f2[j] = f1[j] + f2[j-1] for j in range(W):...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s952005970
p04046
Wrong Answer
base = 10 ** 9 + 7 res = 0 H, W, A, B = map(int, input().split()) f1 = [0 for i in range(W)] for i in range(H-1): #f1 -> #f2 f2 = [0 for j in range(W)] for j in range(W): if j == 0: f2[0] = f1[0] elif i > H-1-A and j<B: f2[j] = f1[j] else: f2[j] = f1[j] + f2[j-1] for j in range(W):...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s026996232
p04046
Wrong Answer
def examD(mod): from operator import mul from functools import reduce def comb2(n, r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1, r + 1)) return over // under H, W, A, B =LI() k = W-B ans = i...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s963368214
p04046
Wrong Answer
H,W,A,B = map(int, input().split()) dp = [[0 for w in range(W)] for h in range(H)] ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s013028743
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) MOD = 10**9+7 ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s331178394
p04046
Wrong Answer
H, W, A, B = map(int, input().split()) path = [[0 for w in range(W)] for h in range(H)] for w in range(W): ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s637642516
p04046
Wrong Answer
#! /usr/bin/env python # -*- coding: utf-8 -*- import pdb import sys F = sys.stdin H, W, A, B = F.readline().rstrip().split() H = int(H) W = int(W) A = int(A) B = int(B) LL = 1e9 + 7 l = [[0] * W] * H l[0] = [1] * W for i in range(1, H - A): for j in range(W): if j == 0: l[i][j] = 1 ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s275543214
p04046
Wrong Answer
import math H, W, A, B = map(int,input().split()) def f(a,b): p = math.factorial(a+b-2) q = math.factorial(a-1) r = math.factorial(b-1) S = p // (q*r) return S T = 0 for i in range(1,B+1): P = f(H-A,i) Q = f(A,W-i+1) T = T + P*Q R = f(H,W) - T ans = R % (10**9+7)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s213686486
p04046
Wrong Answer
import math H, W, A, B = map(int,input().split()) def f(a,b): p = math.factorial(a+b-2) q = math.factorial(a-1) r = math.factorial(b-1) S = p // (q*r) return S T = 0 for i in range(1,B+1): P = f(H-A,i) Q = f(A,W-i+1) T = T + P*Q R = f(H,W) - T print(R)
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s671570977
p04046
Wrong Answer
import math; H, W, a, b = map(int, input().split(' ')) # 中継地点への行き方 * 中継地点からの行き方 ⇛各中継地点をたす ans = 0 # 中間地点へのX、中間地点からのX sgx = b - 1 gx = W - b - 1 sgxp = math.factorial(sgx) gxp = math.factorial(gx) sgyl = H - a for i in range(sgyl): tmp1 = 1 sgy = i sxy = sgx + sgy # for( n = sxy ; sgx != n; n--): ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s702262753
p04046
Wrong Answer
import math; H, W, a, b = map(int, input().split(' ')) # 中継地点への行き方 * 中継地点からの行き方 ⇛各中継地点をたす ans = 0 # 中間地点へのX、中間地点からのX sgx = b - 1 gx = W - b - 1 sgxp = math.factorial(sgx) gxp = math.factorial(gx) sgyl = H - a for i in range(sgyl): tmp1 = 1 sgy = i sxy = sgx + sgy # for( n = sxy ; sgx != n; n--): ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s430850822
p04046
Wrong Answer
# D イロハちゃんと升目 cnt=0 h,w,a,b=map(int,input().split()) def find_power(n): # 0!からn!までのびっくりを出してくれる関数 powlist=[0]*(n+1) powlist[0]=1 powlist[1]=1 for i in range(2,n+1): powlist[i]=powlist[i-1]*i%(10**9+7) return powlist def find_inv_power(n): #0!からn!までの逆元を10**9+7で割ったあまりリストを作る関数 powli...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s164968857
p04046
Wrong Answer
import operator as op from functools import reduce MOD = (10 ** 9) + 7 factors = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, 200010): factors.append(factors[i - 1] * i % MOD) inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD) finv.append(finv[i - 1] * inv[i] % MOD) def nck(n, k): if n < k or ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s406557450
p04046
Wrong Answer
def cmb(n, r, mod): if ( r<0 or r>n ): return 0 else: r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = 200000 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) i...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s295690200
p04046
Wrong Answer
MOD = 10**9 + 7 factorials = [1] for i in range(1, 200000): factorials.append((factorials[-1] * i) % MOD) def combinations(n, k): return (factorials[n] / (factorials[k] * factorials[n - k])) % MOD def f(x, y): return combinations(x + y - 2, x - 1) h, w, a, b = map(int, input().split()) res = 0 for y i...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s254129664
p04046
Wrong Answer
import math mod=10**9+7 h,w,a,b=map(int,input().split()) h1=h-a h2=h w1=b w2=w-b ans=0 for i in range(h1): a=math.factorial(i+w1-1)%mod b=math.factorial(i)%mod c=math.factorial(w1-1)%mod d=math.factorial(h-i-1+w2-1)%mod e=math.factorial(h-i-1)%mod f=math.factorial(w2-1)%mod ans+=((a//(b*c)...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s438504928
p04046
Wrong Answer
def main(): h,w,a,b=map(int,input().split(' ')) mod = 10**9+7 mx=max(h,w) fac=[1]*(h+w+1) for i in range(1,h+w+1): fac[i]=fac[i-1]*i%mod rev=[1]*(mx+1) rev[-1]=pow(fac[mx],mod-2,mod) for i in range(mx-1,-1,-1): rev[i+1]=rev[i+1]*(i+1)%mod const=rev[h-a-1]*rev[a-1]%mod...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s929704301
p04046
Wrong Answer
H,W,A,B = map(int,input().split()) MOD = 10**9 + 7 FAC = [1] INV = [1] for i in range(1,H+W+1): FAC.append((FAC[i-1]*i) % MOD) INV.append(pow(FAC[-1],MOD-2,MOD)) #print(FAC) #print(INV) def nCr(n,r): return FAC[n]*INV[n-r]*INV[r] ans = 0 for i in range(H-A): ans += (nCr(i+B-1,min(i,B-1)) * nCr(H-i-1+W-B-1,min...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s114229006
p04046
Wrong Answer
# coding: utf-8 # Your code here! H,W,A,B=map(int,input().split()) def tansaku(x,y):#これずっと使ったら時間足りなくなりそう ans=1 upper=(x+y) under=min(x,y) for i in range(under): ans*=(upper-i)/(under-i) return ans l_block=1 r_block=tansaku(H-1,W-B-1) ans=l_block*r_block for i in range(1,H-A): l_b...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s676698636
p04046
Wrong Answer
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: ...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
s437216117
p04046
Wrong Answer
h,w,a,b =map(int,input().split()) mod = 10**9+7 #階乗を求める fact_l = [1 for i in range(h+w+1)] for i in range(1,len(fact_l)): fact_l[i] *= (fact_l[i-1]*i)%mod #逆元 factinv_l = [1 for i in range(h+w+1)] for i in range(1,len(fact_l)): factinv_l[i] = pow(fact_l[i],mod-2,mod) #必ず通るポイントまでの組み合わせ point1 = [1 for i i...
2 3 1 1
2
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...