#abc206e. E - Divide Both

E - Divide Both

Score : 500500 points

问题描述

给定整数 LLL,R (LR)L,R\ (L \le R),找出满足以下所有条件的整数对 (x,y)(x,y) 的数目:

  • Lx,yRL \le x,y \le R
  • ggxxyy 的最大公约数(Greatest Common Divisor, GCD)。则满足以下条件:
    • g1g \neq 1,且 xg1\frac{x}{g} \neq 1,同时 yg1\frac{y}{g} \neq 1

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given integers LL and L,R (LR)L,R\ (L \le R), find the number of pairs (x,y)(x,y) of integers satisfying all of the conditions below:

  • Lx,yRL \le x,y \le R
  • Let gg be the greatest common divisor of xx and yy. Then, the following holds.
    • g1g \neq 1, xg1\frac{x}{g} \neq 1, and yg1\frac{y}{g} \neq 1.

Constraints

  • All values in input are integers.
  • 1LR1061 \le L \le R \le 10^6

Input

Input is given from Standard Input in the following format:

LL RR

Output

Print the answer as an integer.

Sample Input 1

3 7

Sample Output 1

2

Let us take some number of pairs of integers, for example.

  • (x,y)=(4,6)(x,y)=(4,6) satisfies the conditions.
  • (x,y)=(7,5)(x,y)=(7,5) has g=1g=1 and thus violates the condition.
  • (x,y)=(6,3)(x,y)=(6,3) has yg=1\frac{y}{g}=1 and thus violates the condition.

There are two pairs satisfying the conditions: (x,y)=(4,6),(6,4)(x,y)=(4,6),(6,4).

Sample Input 2

4 10

Sample Output 2

12

Sample Input 3

1 1000000

Sample Output 3

392047955148

update @ 2024/3/10 09:19:41