結果

問題 No.916 Encounter On A Tree
ユーザー titiatitia
提出日時 2019-10-25 22:34:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 49,552 KB
最終ジャッジ日時 2023-10-11 05:35:26
合計ジャッジ時間 12,182 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,192 KB
testcase_01 AC 17 ms
8,236 KB
testcase_02 AC 301 ms
49,436 KB
testcase_03 AC 308 ms
49,512 KB
testcase_04 AC 299 ms
49,432 KB
testcase_05 AC 296 ms
49,516 KB
testcase_06 AC 296 ms
49,356 KB
testcase_07 AC 298 ms
49,436 KB
testcase_08 AC 52 ms
13,496 KB
testcase_09 AC 88 ms
18,664 KB
testcase_10 AC 17 ms
8,208 KB
testcase_11 AC 17 ms
8,196 KB
testcase_12 AC 297 ms
49,384 KB
testcase_13 AC 299 ms
49,500 KB
testcase_14 AC 297 ms
49,360 KB
testcase_15 AC 302 ms
49,352 KB
testcase_16 AC 88 ms
18,536 KB
testcase_17 AC 299 ms
49,460 KB
testcase_18 AC 16 ms
8,220 KB
testcase_19 AC 298 ms
49,512 KB
testcase_20 AC 304 ms
49,352 KB
testcase_21 AC 303 ms
49,548 KB
testcase_22 AC 307 ms
49,388 KB
testcase_23 AC 297 ms
49,480 KB
testcase_24 AC 300 ms
49,448 KB
testcase_25 AC 303 ms
49,444 KB
testcase_26 AC 158 ms
28,936 KB
testcase_27 AC 159 ms
28,996 KB
testcase_28 AC 91 ms
18,536 KB
testcase_29 AC 301 ms
49,552 KB
testcase_30 AC 296 ms
49,520 KB
testcase_31 AC 319 ms
49,448 KB
testcase_32 AC 299 ms
49,368 KB
testcase_33 AC 161 ms
28,828 KB
testcase_34 AC 89 ms
18,540 KB
testcase_35 AC 52 ms
13,568 KB
testcase_36 AC 304 ms
49,356 KB
testcase_37 AC 302 ms
49,356 KB
testcase_38 AC 89 ms
18,528 KB
testcase_39 AC 302 ms
49,436 KB
testcase_40 AC 304 ms
49,452 KB
testcase_41 AC 16 ms
8,160 KB
testcase_42 AC 16 ms
8,176 KB
testcase_43 AC 16 ms
8,172 KB
testcase_44 AC 16 ms
8,256 KB
testcase_45 AC 52 ms
13,412 KB
testcase_46 AC 16 ms
8,176 KB
testcase_47 AC 17 ms
8,132 KB
testcase_48 AC 16 ms
8,340 KB
testcase_49 AC 16 ms
8,328 KB
testcase_50 AC 17 ms
8,236 KB
testcase_51 AC 17 ms
8,164 KB
testcase_52 AC 16 ms
8,256 KB
testcase_53 AC 16 ms
8,172 KB
testcase_54 AC 16 ms
8,196 KB
testcase_55 AC 16 ms
8,384 KB
testcase_56 AC 17 ms
8,412 KB
testcase_57 AC 17 ms
8,444 KB
testcase_58 AC 19 ms
8,484 KB
testcase_59 AC 21 ms
8,916 KB
testcase_60 AC 26 ms
9,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

d,l,r,k=map(int,input().split())

TWO=[2**i for i in range(23)]

mod=10**9+7

FACT=[1]
for i in range(1,(1<<d)+1):
    FACT.append(FACT[-1]*i%mod)

for i in range(23):
    if l<TWO[i]:
        lh=i
        break

for i in range(23):
    if r<TWO[i]:
        rh=i
        break

if l==1:
    if rh-lh==k:
        ANS=1
        for i in range(d):
            ANS=ANS*FACT[1<<i]%mod

        print(ANS)

    else:
        print(0)
    
    
elif (lh+rh)%2==k%2 and abs(lh-rh)<=k<=lh+rh:
    ANS=1
    for i in range(d):
        ANS=ANS*FACT[1<<i]%mod

    #print(ANS)

    kei=(k-(rh-lh))//2

    #print(kei)

    if lh==rh:
        ANS=ANS*pow((1<<(lh-1))-1,mod-2,mod)*pow(2,kei-1,mod)%mod

        print(ANS)

    else:
        ANS=ANS*pow((1<<(lh-1)),mod-2,mod)*pow(2,max(kei,1)-1,mod)%mod

        print(ANS)

else:
    print(0)
0