100 atcoder#ABC142D. [ABC142D] Disjoint Set of Common Divisors
[ABC142D] Disjoint Set of Common Divisors
Score : points
Problem Statement
Given are positive integers and .
Let us choose some number of positive common divisors of and .
Here, any two of the chosen divisors must be coprime.
At most, how many divisors can we choose?
Definition of common divisor
An integer is said to be a common divisor of integers and when divides both and .
Definition of being coprime
Integers and are said to be coprime when and have no positive common divisors other than .
Definition of dividing
An integer is said to divide another integer when there exists an integer such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum number of divisors that can be chosen to satisfy the condition.
12 18
3
and have the following positive common divisors: , , , and .
and are coprime, and are coprime, and and are coprime, so we can choose , , and , which achieve the maximum result.
420 660
4
1 2019
1
and have no positive common divisors other than .