結果

問題 No.916 Encounter On A Tree
ユーザー stngstng
提出日時 2022-08-14 21:53:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,302 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 75,900 KB
最終ジャッジ日時 2024-04-08 22:15:06
合計ジャッジ時間 5,089 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 64 ms
75,900 KB
testcase_03 AC 64 ms
75,900 KB
testcase_04 AC 65 ms
75,900 KB
testcase_05 AC 64 ms
75,900 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 44 ms
61,564 KB
testcase_09 AC 47 ms
63,612 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 38 ms
53,460 KB
testcase_12 AC 64 ms
75,900 KB
testcase_13 AC 64 ms
75,868 KB
testcase_14 AC 64 ms
75,900 KB
testcase_15 AC 63 ms
75,900 KB
testcase_16 AC 48 ms
63,612 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 63 ms
75,900 KB
testcase_23 WA -
testcase_24 AC 64 ms
75,900 KB
testcase_25 WA -
testcase_26 AC 53 ms
67,708 KB
testcase_27 WA -
testcase_28 AC 47 ms
63,580 KB
testcase_29 WA -
testcase_30 AC 66 ms
75,900 KB
testcase_31 AC 64 ms
75,900 KB
testcase_32 AC 64 ms
75,900 KB
testcase_33 AC 52 ms
67,708 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 63 ms
75,900 KB
testcase_37 AC 65 ms
75,900 KB
testcase_38 WA -
testcase_39 AC 65 ms
75,868 KB
testcase_40 AC 65 ms
75,900 KB
testcase_41 AC 35 ms
53,460 KB
testcase_42 AC 36 ms
53,460 KB
testcase_43 AC 36 ms
53,460 KB
testcase_44 AC 36 ms
53,460 KB
testcase_45 AC 44 ms
61,564 KB
testcase_46 AC 35 ms
53,460 KB
testcase_47 AC 37 ms
53,460 KB
testcase_48 AC 35 ms
53,460 KB
testcase_49 AC 36 ms
53,460 KB
testcase_50 AC 36 ms
53,460 KB
testcase_51 AC 35 ms
53,460 KB
testcase_52 WA -
testcase_53 AC 37 ms
53,460 KB
testcase_54 AC 37 ms
53,460 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 41 ms
59,464 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

d,L,R,k = map(int,input().split())

MOD = 10**9+7
N = 2**d

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] * rfact[n-k] % MOD

rui = []
val = 1
for i in range(d):
    rui.append(val)
    if L >= val:
        lidx = i
    if R >= val:
        ridx = i
    val *= 2

ans = 1

f = False
if lidx == ridx:
    f = True
    if k % 2 != 0 or k > 2*lidx:
        print(0)
        exit()
else:
    if k % 2 != (ridx-lidx) % 2 or k > lidx+ridx:
        print(0)
        exit()

if f == True:
    for i in range(d):
        if i == lidx:
            tmp = pow(2,i,MOD)
            if tmp == 2:
                ans *= tmp*1*perm(tmp-2,tmp-2)
            else:
                ans *= tmp*2*perm(tmp-2,tmp-2)
            ans %= MOD
            continue
        tmp = pow(2,i,MOD)
        ans *= perm(tmp,tmp)
        ans %= MOD
    print(ans%MOD)
else:
    for i in range(d):
        if i == lidx:
            tmp = pow(2,i,MOD)
            ans *= perm(tmp-1,tmp-1)
            ans %= MOD
            continue
        tmp = pow(2,i,MOD)
        ans *= perm(tmp,tmp)
        ans %= MOD
    print(ans%MOD)
0