結果

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

テストケース

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

ソースコード

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()
#print(lidx,ridx)
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)
            if tmp != 1:
                aa = k // 2
                aa = int(aa)
                ans *= (2**(aa-1))*perm(tmp-1,tmp-1)
            else:
                ans *= perm(tmp-1,tmp-1)
            ans %= MOD
            continue
        tmp = pow(2,i,MOD)
        ans *= perm(tmp,tmp)
        ans %= MOD
    print(ans%MOD)
0