eolymp
bolt
Try our new interface for solving problems
Problems

Arithmetic Masha

Arithmetic Masha

Misha writes \textbf{2} numbers: \textbf{n} and \textbf{m}, and Masha must divide the number \textbf{n} into \textbf{m} parts, without changing the order of digits. Misha still requires that the product obtained by \textbf{m} numbers is maximum. Help Masha. \InputFile The input data contains several test cases. Each test case is located on a separate line and contains two numbers separated with a space: first, \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{10^15}), then \textbf{m} (\textbf{1} ≤ \textbf{m} ≤ \textbf{\[lg(n)\]}). \OutputFile For each test case print in a separate line the maximum product.
Time limit 1 second
Memory limit 64 MiB
Input example #1
12345 2
12345 3
Output example #1
6170
2460
Source Team Cup Ukraine 2011 - schoolchildren - Round 1