結果

問題 No.916 Encounter On A Tree
ユーザー titiatitia
提出日時 2019-10-25 22:29:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 49,548 KB
最終ジャッジ日時 2023-10-11 05:23:36
合計ジャッジ時間 11,630 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,348 KB
testcase_01 AC 16 ms
8,232 KB
testcase_02 AC 297 ms
49,340 KB
testcase_03 AC 305 ms
49,364 KB
testcase_04 AC 296 ms
49,356 KB
testcase_05 WA -
testcase_06 AC 299 ms
49,352 KB
testcase_07 AC 306 ms
49,344 KB
testcase_08 AC 51 ms
13,544 KB
testcase_09 AC 90 ms
18,684 KB
testcase_10 AC 16 ms
8,248 KB
testcase_11 AC 16 ms
8,248 KB
testcase_12 AC 295 ms
49,492 KB
testcase_13 AC 302 ms
49,368 KB
testcase_14 AC 301 ms
49,388 KB
testcase_15 AC 300 ms
49,500 KB
testcase_16 AC 87 ms
18,700 KB
testcase_17 WA -
testcase_18 AC 16 ms
8,352 KB
testcase_19 AC 301 ms
49,352 KB
testcase_20 AC 301 ms
49,352 KB
testcase_21 WA -
testcase_22 AC 300 ms
49,528 KB
testcase_23 WA -
testcase_24 AC 304 ms
49,488 KB
testcase_25 AC 303 ms
49,356 KB
testcase_26 AC 161 ms
28,840 KB
testcase_27 AC 160 ms
28,832 KB
testcase_28 AC 87 ms
18,716 KB
testcase_29 WA -
testcase_30 AC 303 ms
49,528 KB
testcase_31 AC 303 ms
49,532 KB
testcase_32 AC 305 ms
49,504 KB
testcase_33 AC 158 ms
28,832 KB
testcase_34 AC 88 ms
18,564 KB
testcase_35 AC 52 ms
13,400 KB
testcase_36 AC 297 ms
49,528 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 299 ms
49,380 KB
testcase_40 AC 303 ms
49,440 KB
testcase_41 AC 16 ms
8,208 KB
testcase_42 AC 16 ms
8,328 KB
testcase_43 AC 16 ms
8,380 KB
testcase_44 AC 16 ms
8,372 KB
testcase_45 AC 51 ms
13,384 KB
testcase_46 AC 17 ms
8,160 KB
testcase_47 AC 16 ms
8,316 KB
testcase_48 AC 16 ms
8,344 KB
testcase_49 AC 16 ms
8,324 KB
testcase_50 AC 16 ms
8,196 KB
testcase_51 AC 16 ms
8,320 KB
testcase_52 WA -
testcase_53 AC 16 ms
8,320 KB
testcase_54 AC 16 ms
8,340 KB
testcase_55 AC 16 ms
8,388 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 18 ms
8,668 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

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,kei,mod)%mod

        print(ANS)

else:
    print(0)
0