結果

問題 No.1683 Robot Guidance
ユーザー tassei903tassei903
提出日時 2021-09-17 23:29:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,826 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 269,916 KB
最終ジャッジ日時 2023-09-12 09:36:18
合計ジャッジ時間 35,294 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 678 ms
269,556 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 674 ms
269,352 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 680 ms
269,472 KB
testcase_17 AC 691 ms
269,592 KB
testcase_18 AC 683 ms
269,540 KB
testcase_19 AC 691 ms
269,432 KB
testcase_20 AC 690 ms
269,564 KB
testcase_21 AC 688 ms
269,496 KB
testcase_22 WA -
testcase_23 AC 676 ms
269,532 KB
testcase_24 WA -
testcase_25 AC 685 ms
269,368 KB
testcase_26 AC 689 ms
269,432 KB
testcase_27 WA -
testcase_28 AC 673 ms
269,360 KB
testcase_29 AC 673 ms
269,500 KB
testcase_30 AC 672 ms
269,460 KB
testcase_31 AC 669 ms
269,524 KB
testcase_32 AC 667 ms
269,216 KB
testcase_33 AC 669 ms
269,660 KB
testcase_34 AC 665 ms
269,456 KB
testcase_35 AC 670 ms
269,428 KB
testcase_36 AC 675 ms
269,804 KB
testcase_37 AC 692 ms
269,632 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 728 ms
269,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
p = 10 ** 9 + 7
mod = p
N = 3*10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return ((fact[n] * factinv[r])%p) * factinv[n-r] % p

def pem(n,r):
    if (r < 0) or (n < r):
        return 0
    return (fact[n] * factinv[r])%p

b,a,x,y = na()
if a==0:
    if x==b and y==0:
        print(1)
    else:
        print(0)
elif a==1:
    if x+y==b and x>=0 and y>=0:
        print(1)
    else:
        print(0)
elif a==2:
    if abs(x)+y<=b and (x+y-b)%2==0 and y>=0:
        print(1)
    else:
        print(0)
else:
    if (x+y-b)%2 or abs(x)+abs(y)>b:
        print(0)
    else:
        r,l,u,d = 0,0,0,0
        rr,ll,uu,dd = a//4,(a-1)//4,(a-2)//4,(a-3)//4
        ans = 0
        c = (b-abs(x)-abs(y))//2
        if x>0:
            r = x
        else:
            l = -x
        if y>0:
            u = y
        else:
            d = -y
        for i in range(c+1):
            ans+=cmb(rr+r+i,rr)*cmb(ll+l+i,ll)%mod*cmb(uu+u+c-i,uu)%mod*cmb(dd+d+c-i,dd)%mod
            ans%=mod
            print(cmb(rr+r+i,rr),cmb(ll+l+i,ll),cmb(uu+u+c-i,uu),cmb(dd+d+c-i,dd))
        print(ans)
0