#T68. 乘积最大
乘积最大
Description
This year marks the "2000—World Year of Mathematics" as designated by the International Mathematical Union, and it also coincides with the 90th anniversary of the birth of the renowned Chinese mathematician Hua Luogeng. In Hua Luogeng's hometown of Jintan, Jiangsu, a unique mathematical intelligence competition was organized, and your good friend XZ was fortunate enough to participate. During the event, the host presented the following problem to all contestants:
Given a numeric string of length N, the contestants are required to divide it into K+1 parts using K multiplication signs and find a division method that maximizes the product of these K+1 parts.
To help the contestants understand the problem correctly, the host provided the following example:
For the numeric string "312", when N=3 and K=1, there are two possible division methods:
- 3*12=36
- 31*2=62
In this case, the correct result that meets the problem's requirements is: 31*2=62.
Now, please help your good friend XZ design a program to find the correct answer.
Input Format
The first line contains two natural numbers, N and K (6 ≤ N ≤ 10, 1 ≤ K ≤ 6).
The second line is a numeric string of length N.
Output Format
Output the maximum product obtained (a natural number).
4 2
1231
62