eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Not so Flat After All

Not so Flat After All

\includegraphics{https://static.e-olymp.com/content/f7/f72d30aa52a1f65a0e11118af55e903294053fa5.jpg} Any positive integer \textbf{v} can be written as \textbf{p_1^a1}*\textbf{p_2}^a2*...*\textbf{p_n^an} where \textbf{p_i} is a prime number and \textbf{a_i} ≥ \textbf{0}. For example: \textbf{24} = \textbf{2^3}*\textbf{3^1}. Pick any two prime numbers \textbf{p_1} and \textbf{p_2} where \textbf{p_1} ≠ \textbf{p_2}. Imagine a two dimensional plane where the powers of \textbf{p_1} are plotted on the \textbf{x}-axis and the powers of \textbf{p_2} on the yaxis. Now any number that can be written as \textbf{p_1^a1}*\textbf{p_2^a2} can be plotted on this plane at location (\textbf{x}, \textbf{y}) = (\textbf{a_1}, \textbf{a_2}). The figure on the right shows few examples where \textbf{p_1} = \textbf{3} and \textbf{p_2} = \textbf{2}. This idea can be extended for any \textbf{N}-Dimensional space where each of the \textbf{N} axes is assigned a unique prime number. Each \textbf{N}-Dimensional space has a unique set of primes. We call such set the Space Identification Set or \textbf{S} for short. |\textbf{S}| (the ordinal of \textbf{S}) is \textbf{N}. \includegraphics{http://acm.hdu.edu.cn/data/images/shuyu.jpg} \includegraphics{http://acm.hdu.edu.cn/data/images/baohanyu.jpg} Any number that can be expressed as a multiplication of \textbf{p_iS} (each raised to a power (\textbf{a_i} ≥ \textbf{0}) can be plotted in this |\textbf{S}|-Dimensional space. The figure at the bottom illustrates this idea for \textbf{N} = \textbf{3} and \textbf{S} = \{\textbf{2}, \textbf{3}, \textbf{7}\}. Needless to say, any number that can be plotted on space \textbf{A} can also be plotted on space \textbf{B} as long as \textbf{S_AS_B}. We define the distance between any two points in a given \textbf{N}-Dimensional space to be the sum of units traveled to get from one point to the other while following the grid lines (i.e. movement is always parallel to one of the axes.) For example, in the figure below, the distance between \textbf{168} and \textbf{882} is \textbf{4}. Given two positive integers, write a program that determines the minimum ordinal of a space where both numbers can be plotted in. The program also determines the distance between these two integers in that space. \includegraphics{https://static.e-olymp.com/content/21/212f5129cebaccc3b70d195f211eb1e253e36e2c.jpg} \InputFile Your program will be tested on one or more test cases. Each test case is specified on a line with two positive integers (\textbf{0} < \textbf{A}, \textbf{B} < \textbf{1, 000, 000}) where \textbf{A}*\textbf{B} > \textbf{1}. The last line is made of two zeros. \OutputFile For each test case, print the following line: \textbf{k.} \textbf{X:D} Where \textbf{k} is the test case number (starting at one,) \textbf{X} is the minimum ordinal needed in a space that both \textbf{A} and \textbf{B} can be plotted in. \textbf{D} is the distance between these two points. \textbf{Note}: There is a blank space before \textbf{X}.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
168 882
770 792
0 0
Вихідні дані #1
1. 3:4
2. 5:6