Anti-Division

AtCoder
IDabc131_c
Time2000ms
Memory256MB
Difficulty
You are given four integers $A$, $B$, $C$, and $D$. Find the number of integers between $A$ and $B$ (inclusive) that can be evenly divided by neither $C$ nor $D$. ## Constraints * $1\leq A\leq B\leq 10^{18}$ * $1\leq C,D\leq 10^9$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $A$ $B$ $C$ $D$ [samples]
Samples
Input #1
4 9 2 3
Output #1
2

$5$ and $7$ satisfy the condition.
Input #2
10 40 6 8
Output #2
23
Input #3
314159265358979323 846264338327950288 419716939 937510582
Output #3
532105071133627368
API Response (JSON)
{
  "problem": {
    "name": "Anti-Division",
    "description": {
      "content": "You are given four integers $A$, $B$, $C$, and $D$. Find the number of integers between $A$ and $B$ (inclusive) that can be evenly divided by neither $C$ nor $D$.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc131_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given four integers $A$, $B$, $C$, and $D$. Find the number of integers between $A$ and $B$ (inclusive) that can be evenly divided by neither $C$ nor $D$.\n\n## Constraints\n\n*   $1\\leq A\\leq B\\l...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments