Divide Both

AtCoder
IDabc206_e
Time2000ms
Memory256MB
Difficulty
Given integers $L$ and $L,R\ (L \le R)$, find the number of pairs $(x,y)$ of integers satisfying all of the conditions below: * $L \le x,y \le R$ * Let $g$ be the greatest common divisor of $x$ and $y$. Then, the following holds. * $g \neq 1$, $\frac{x}{g} \neq 1$, and $\frac{y}{g} \neq 1$. ## Constraints * All values in input are integers. * $1 \le L \le R \le 10^6$ ## Input Input is given from Standard Input in the following format: $L$ $R$ [samples]
Samples
Input #1
3 7
Output #1
2

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

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

There are two pairs satisfying the conditions: $(x,y)=(4,6),(6,4)$.
Input #2
4 10
Output #2
12
Input #3
1 1000000
Output #3
392047955148
API Response (JSON)
{
  "problem": {
    "name": "Divide Both",
    "description": {
      "content": "Given integers $L$ and $L,R\\ (L \\le R)$, find the number of pairs $(x,y)$ of integers satisfying all of the conditions below: *   $L \\le x,y \\le R$ *   Let $g$ be the greatest common divisor of $x$ a",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc206_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given integers $L$ and $L,R\\ (L \\le R)$, find the number of pairs $(x,y)$ of integers satisfying all of the conditions below:\n\n*   $L \\le x,y \\le R$\n*   Let $g$ be the greatest common divisor of $x$ a...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments