Submission #2703102


Source Code Expand

import math

def f(x, y, n):
    r = 0
    if x * y < n:
        r = 0
    elif n == 1:
        r =  1 if x*y == 1 else 0
    elif x != 1 and y != 1 and n == 2:
        r = 2
    elif x == 1 and y != 1 and n >= 2 :
        r = math.factorial(y-2)//math.factorial(n-2)
    elif x != 1 and y == 1 and n >= 2:
        r = math.factorial(x-2)//math.factorial(n-2)
    elif x == 2 and y == 2 and n == 3:
        r = 4
    elif x == 2 and y == 2 and n == 4:
        r = 1
    else:
        a = math.factorial(x*y)//math.factorial(n)//math.factorial(x*y-n)
        b = 0
        for x_ in range(x, 0, -1):
            for y_ in range(y, 0, -1):
                if x_ != x or y_ != y:
                    b += (x-x_+1) * (y-y_+1) * f(x_, y_, n)
        r = a - b
    
    return r

R, C = map(int, input().split())
X, Y = map(int, input().split())
D, L = map(int, input().split())

print((f(X, Y, D+L)*(R+1-X)*(C+1-Y)*math.factorial(D+L)//math.factorial(D)//math.factorial(L)) % 1000000007)

Submission Info

Submission Time
Task A - AtCoder社の給料
User sgrsgr
Language Python (3.4.3)
Score 0
Code Size 1017 Byte
Status RE
Exec Time 19 ms
Memory 3064 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
RE × 14
Set Name Test Cases
All 00_sample_01.txt, 00_sample_02.txt, test_100.txt, test_14.txt, test_29.txt, test_4.txt, test_42.txt, test_48.txt, test_54.txt, test_59.txt, test_71.txt, test_72.txt, test_84.txt, test_96.txt
Case Name Status Exec Time Memory
00_sample_01.txt RE 18 ms 3064 KB
00_sample_02.txt RE 17 ms 3064 KB
test_100.txt RE 18 ms 3064 KB
test_14.txt RE 17 ms 3064 KB
test_29.txt RE 18 ms 3064 KB
test_4.txt RE 18 ms 3064 KB
test_42.txt RE 18 ms 3064 KB
test_48.txt RE 18 ms 3064 KB
test_54.txt RE 18 ms 3064 KB
test_59.txt RE 19 ms 3064 KB
test_71.txt RE 17 ms 3064 KB
test_72.txt RE 17 ms 3064 KB
test_84.txt RE 18 ms 3064 KB
test_96.txt RE 18 ms 3064 KB