Disjoint Set of Common Divisors

AtCoder
IDabc142_d
Time2000ms
Memory256MB
Difficulty
Given are positive integers $A$ and $B$. Let us choose some number of positive common divisors of $A$ and $B$. Here, any two of the chosen divisors must be coprime. At most, how many divisors can we choose? Definition of common divisor An integer $d$ is said to be a common divisor of integers $x$ and $y$ when $d$ divides both $x$ and $y$. Definition of being coprime Integers $x$ and $y$ are said to be coprime when $x$ and $y$ have no positive common divisors other than $1$. Definition of dividing An integer $x$ is said to divide another integer $y$ when there exists an integer $\alpha$ such that $y = \alpha x$. ## Constraints * All values in input are integers. * $1 \leq A, B \leq 10^{12}$ ## Input Input is given from Standard Input in the following format: $A$ $B$ [samples]
Samples
Input #1
12 18
Output #1
3

$12$ and $18$ have the following positive common divisors: $1$, $2$, $3$, and $6$.
$1$ and $2$ are coprime, $2$ and $3$ are coprime, and $3$ and $1$ are coprime, so we can choose $1$, $2$, and $3$, which achieve the maximum result.
Input #2
420 660
Output #2
4
Input #3
1 2019
Output #3
1

$1$ and $2019$ have no positive common divisors other than $1$.
API Response (JSON)
{
  "problem": {
    "name": "Disjoint Set of Common Divisors",
    "description": {
      "content": "Given are positive integers $A$ and $B$. Let us choose some number of positive common divisors of $A$ and $B$. Here, any two of the chosen divisors must be coprime. At most, how many divisors can we c",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc142_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given are positive integers $A$ and $B$.\nLet us choose some number of positive common divisors of $A$ and $B$.\nHere, any two of the chosen divisors must be coprime.\nAt most, how many divisors can we c...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments