結果

問題 No.1683 Robot Guidance
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-09-18 10:04:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,021 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 259,304 KB
最終ジャッジ日時 2023-09-12 19:26:22
合計ジャッジ時間 15,626 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 276 ms
259,004 KB
testcase_02 AC 284 ms
259,112 KB
testcase_03 RE -
testcase_04 AC 295 ms
259,012 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 296 ms
259,232 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 275 ms
259,096 KB
testcase_17 AC 272 ms
258,904 KB
testcase_18 AC 281 ms
259,084 KB
testcase_19 WA -
testcase_20 AC 273 ms
259,060 KB
testcase_21 WA -
testcase_22 AC 267 ms
259,304 KB
testcase_23 WA -
testcase_24 RE -
testcase_25 AC 279 ms
259,200 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 269 ms
258,712 KB
testcase_29 AC 272 ms
259,292 KB
testcase_30 AC 273 ms
258,996 KB
testcase_31 AC 282 ms
259,108 KB
testcase_32 WA -
testcase_33 AC 310 ms
259,116 KB
testcase_34 WA -
testcase_35 AC 307 ms
259,228 KB
testcase_36 WA -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b,x,y = map(int,input().split())
mod = 10**9+7

### for bigger prime 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,10**6+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]%mod*finv[n-r]%mod


ans = 0
r = (b+4)//4
u = (b+3)//4
l = (b+2)//4
d = (b+1)//4

for i in range(a+1):
    if i < x:
        continue
    dif = i-x
    left = a-i-dif
    base = nCr(i+r-1,i,mod)*nCr(dif+l-1,dif,mod)%mod
    if left < abs(y):
        continue
    if y >= 0:
        left -= y
        if left%2:
            continue
        need = y+left//2
        base *= nCr(need+u-1,need,mod)*nCr(left//2+d-1,d-1,mod)%mod
        base %= mod
    
    else:
        left += y
        if left%2:
            continue
        need = -y+left//2
        base *= nCr(need+u-1,need,mod)*nCr(left//2+d-1,mod)%mod
        base %= mod
    ans += base
    ans %= mod
print(ans)
0