結果

問題 No.916 Encounter On A Tree
ユーザー ningenMeningenMe
提出日時 2019-03-21 15:13:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 808 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 20,592 KB
最終ジャッジ日時 2023-10-19 05:20:24
合計ジャッジ時間 8,681 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
20,592 KB
testcase_01 AC 109 ms
20,592 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 110 ms
20,592 KB
testcase_09 AC 108 ms
20,592 KB
testcase_10 AC 108 ms
20,592 KB
testcase_11 AC 111 ms
20,592 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 110 ms
20,592 KB
testcase_17 RE -
testcase_18 AC 109 ms
20,592 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 109 ms
20,592 KB
testcase_27 AC 109 ms
20,592 KB
testcase_28 AC 110 ms
20,592 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 110 ms
20,592 KB
testcase_34 AC 110 ms
20,592 KB
testcase_35 AC 110 ms
20,592 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 AC 110 ms
20,592 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 113 ms
20,592 KB
testcase_42 AC 110 ms
20,592 KB
testcase_43 AC 115 ms
20,592 KB
testcase_44 AC 109 ms
20,592 KB
testcase_45 AC 110 ms
20,592 KB
testcase_46 AC 111 ms
20,592 KB
testcase_47 AC 112 ms
20,592 KB
testcase_48 AC 110 ms
20,592 KB
testcase_49 AC 109 ms
20,592 KB
testcase_50 AC 110 ms
20,592 KB
testcase_51 AC 110 ms
20,592 KB
testcase_52 AC 116 ms
20,592 KB
testcase_53 AC 110 ms
20,592 KB
testcase_54 AC 110 ms
20,592 KB
testcase_55 AC 108 ms
20,592 KB
testcase_56 AC 110 ms
20,592 KB
testcase_57 AC 111 ms
20,592 KB
testcase_58 AC 110 ms
20,592 KB
testcase_59 AC 109 ms
20,592 KB
testcase_60 AC 114 ms
20,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
MOD = 1000000000 + 7
d,l,r,k = map(int,input().split())
pow2 = []
acc = []
fac = []
pow2.append(1)
pow2.append(1)
for i in range(2,20):
  pow2.append(pow2[-1]*2)
acc.append(0)
acc.append(1)
for i in range(2,20):
  acc.append(acc[-1]+pow2[i])
fac.append(1)
fac.append(1)
for i in range(2,pow2[19]+1):
  fac.append((fac[-1]*i)%MOD)

l = bisect_left(acc,l)
r = bisect_left(acc,r)

lca = -1
ans = 1
if l + r - k > 1 and (l + r -k)%2 == 0:
  lca = (l + r -k) //2
if lca == -1 or lca > l or lca > r:
  ans = 0

for i in range(1,d+1):
  cnt = pow2[i]
  if i == l:
    cnt-=1
  if i == r:
    cnt-=1
  ans *= fac[cnt]
  ans %= MOD

if ans != 0:
  ans *= pow2[lca]
  ans %= MOD
  ans *= pow2[l - lca]
  ans %= MOD
  ans *= pow2[r - lca]
  ans %= MOD
  ans *= 2
  ans %= MOD

print(ans)
0