#P1018. [NOIP 2000 提高组] 乘积最大

    ID: 18 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划,dp高精度2000NOIp 提高组

[NOIP 2000 提高组] 乘积最大

Description

The year 2000 was designated as the World Year of Mathematics by the International Mathematical Union, and it also marked the 90th birth anniversary of the renowned Chinese mathematician Hua Luogeng. In Jintan, Jiangsu, Hua Luogeng’s hometown, a special mathematics contest was held. Your good friend XZ participated, and the host posed the following problem:

Given a numeric string of length NN, insert KK multiplication signs to split it into K+1K + 1 parts. Find a way to split it so that the product of these K+1K + 1 parts is maximized.

To help participants understand the problem, the host gave the following example:

Given the numeric string 312312, when N=3,K=1N = 3, K = 1, there are two ways to split it:

  1. 3×12=363 \times 12 = 36.
  2. 31×2=6231 \times 2 = 62.

In this case, the correct result is 31×2=6231 \times 2 = 62.

Now, please help your friend XZ write a program to compute the correct answer.

Input Format

The input consists of two lines:

  • The first line contains two natural numbers N,KN, K.
  • The second line contains a numeric string of length NN.

Output Format

Output the maximum product (a natural number) corresponding to the given input.

4 2
1231

62

Hint

Constraints

  • For 60%60\% of the testdata: 6N206 \le N \le 20.
  • For all testdata: 6N406 \le N \le 40, 1K61 \le K \le 6.

Translated by ChatGPT 5