luogu#P3653. 小清新数学题

    ID: 2682 远端评测题 3000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>O2优化枚举素数判断,质数,筛法前缀和

小清新数学题

Background

Time limit: 3 s.

Friendly reminder: https://www.luogu.com.cn/problem/P3601.

Problem Description

Let's keep the problem simple.

We define the Möbius function μ(x)\mu(x). If each prime factor of xx appears only once and there are pp prime factors, then μ(x)=(1)p\mu(x)=(-1)^p; otherwise, μ(x)=0\mu(x)=0.

You are asked to compute i=lrμ(i)\sum_{i=l}^r \mu(i).

Input Format

One line contains two integers l,rl,r.

Output Format

One line contains one integer representing the answer.

1 233
-1
99999999999899999 99999999999999999
421

Hint

For 10%10\% of the testdata, l,r106l,r \leq 10^6.

For 30%30\% of the testdata, l,r1012l,r \leq 10^{12}.

For 100%100\% of the testdata, 1lr10181 \leq l \leq r \leq 10^{18}, rl105r-l \leq 10^5.

Translated by ChatGPT 5