UVA11440 帮帮Tomisu Help Tomisu(欧拉函数)
题目:
请求出在2到N!之间有多少个整数x,满足其质因子都大于M
思路:
1."质因子都大于M"等价于 和M!互质
2.
g
c
d
(
a
,
b
)
=
g
c
d
(
a
m
o
d
b
,
b
)
gcd(a,b)=gcd(a \mod b,b)
gcd(a,b)=gcd(amodb,b)
a
n
s
=
p
h
i
(
M
!
)
∗
N
!
/
M
!
ans=phi(M!)*N!/M!
ans=phi(M!)∗N!/M!
令
p
h
i
f
a
c
(
n
)
=
p
h
i
(
n
!
)
phifac(n)=phi(n!)
phifac(n)=phi(n!),则
p
h
i
f
a
c
[
i
]
=
p
h
i
f
a
c
[
i
−
1
]
∗
(
v
i
s
[
i
]
?
i
:
i
−
1
)
%
m
o
d
phifac[i]=phifac[i-1]*(vis[i]?i:i-1)\%mod
phifac[i]=phifac[i−1]∗(vis[i]?i:i−1)%mod