#P1326. Intersection Set of Prime Factors
Intersection Set of Prime Factors
Intersection Set of Prime Factors
题目描述
Given a positive integer . Select two distinct digits from the decimal repersentation(十进制表示)of , we obtain another integer . What is the size of the intersection set(交集)of the prime factors of and ? For example, given , its prime factor set is . Swapping and gives us , of which the prime factor set is . Then the intersection set of and is , with factors.
输入格式
Each input file contains one test case, which gives a positive integer . It is guaranteed that there are at least distinct digits in .
输出格式
Swap any pair of digits in to obtain , you are supposed to find the with the largest intersection set of the prime factors of and . Output in a line the number of the prime factors in the intersection set, together with . The numbers must be separated by space, and there must be no extra space at the beginning or the end of the line. In case such an is not unique, output the one with the smallest value.
样例 #1
样例输入 #1
623457198
样例输出 #1
4 123457698
提示
There are two with common factors. Besides the one given in the problem description, we can also swap and to obtain . This number has a prime factor set , and so the intersection set is also . This number is in the ouput because it is smaller than .