PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000091. Chọn nhiều ước chung đôi một nguyên tố cùng nhau (Disjoint Set of Common Divisors)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chọn nhiều ước chung đôi một nguyên tố cùng nhau (Disjoint Set of Common Divisors)
Disjoint Set of Common Divisors
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given two positive integers and , choose a set of their positive common divisors. Every two distinct chosen divisors must be coprime (their GCD is ). Find the maximum possible number of chosen divisors. The number is a valid common divisor.
Input
One line containing and .
Output
Print the maximum possible size of the set.
Subtasks
- Subtask 1 (20 points):
- Subtask 2 (30 points):
- Subtask 3 (50 points):
Examples
Input
12 18
Output
3
Explanation
The common divisors are . The set has three elements and is pairwise coprime. The divisor cannot be added together with either or , so the maximum is .