AtCoder Beginner Contest 142
D
Disjoint Set of Common Divisors
AtCoder
⌀ 827
原题
← CE →
翻译中…

Problem Statement

翻译中…

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

翻译中…

Output

翻译中…

Print the maximum number of divisors that can be chosen to satisfy the condition.

翻译中…

样例

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$.
题目信息
题号
abc142_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。