D. Easy Math
Given a positive integers nn , Mobius function \mu(n)μ(n) is defined as follows:
\displaystyle \mu(n) = \begin{cases} 1 &n = 1 \\ (-1)^k & n = p_1p_2\cdots p_k \\ 0 &other \end{cases}μ(n)=⎩⎪⎨⎪⎧1(−1)k0n=1n=p1p2⋯pkother
p_i (i = 1, 2, \cdots, k)pi(i=1,2,⋯,k) are different prime numbers.
Given two integers mm, nn, please calculate \sum_{i = 1}^{m} \mu(in)∑i=1mμ(in).
Input
One line includes two integers m (1 \le m \le 2e9)m(1≤m≤2e9), n (1 \le n \le 1e12)n(1≤n≤1e12) .
Output
One line includes the answer .
样例输入
2 2
样例输出
-1
题意:
已知,求
思路:
不需要递归,更不需要容斥!直接将min_25修改一下即可,20ms
Min_25筛:https://blog.csdn.net/Jaihk662/article/details/82024131
可以分析出这题的递推公式就是:
答案就是
其中T表示大于等于第y个质数且小于m且不是n的因子的质数个数,右边的求和中不能为n的因子
复杂度约为O()
#include
#include
#include
#include