「BJOI2019」奥术神杖(AC自动机+DP)
作者:互联网
文章目录
title
solution
令
M
a
g
i
c
=
V
i
×
V
j
×
V
k
.
.
.
Magic=V_i\times V_j\times V_k...
Magic=Vi×Vj×Vk...
这里对
M
a
g
i
c
c
\sqrt[c]{Magic}
cMagic
有一个很巧妙的转换——取对数
M
a
g
i
c
c
=
(
M
a
g
i
c
)
1
c
=
e
l
o
g
e
(
M
a
g
i
c
)
1
c
\sqrt[c]{Magic}=(Magic)^{\frac{1}{c}}=e^{log_e(Magic)^{\frac{1}{c}}}
cMagic
=(Magic)c1=eloge(Magic)c1
l
o
g
e
M
a
g
i
c
1
c
=
1
c
l
o
g
e
M
a
g
i
c
=
1
c
l
o
g
e
(
V
i
×
V
j
×
V
k
.
.
.
)
log_e\ Magic^{\frac{1}{c}}=\frac{1}{c}log_e\ Magic=\frac{1}{c}log_e(V_i\times V_j\times V_k...)
loge Magicc1=c1loge Magic=c1loge(Vi×Vj×Vk...)
=
1
c
×
(
l
o
g
e
V
i
+
l
o
g
e
V
j
+
l
o
g
e
V
k
.
.
.
)
=\frac{1}{c}\times (log_eV_i+log_eV_j+log_eV_k...)
=c1×(logeVi+logeVj+logeVk...)
于是就成功把神力值的相乘开方变为了相加
(
l
o
g
e
V
i
+
l
o
g
e
V
j
+
l
o
g
e
V
k
.
.
.
c
)
m
a
x
(\frac{log_eV_i+log_eV_j+log_eV_k...}{c})_{max}
(clogeVi+logeVj+logeVk...)max
标签:BJOI2019,奥术,Magic,int,AC,trie,maxn,now,dp 来源: https://blog.csdn.net/Emm_Titan/article/details/111657444