# Codevs 1017 Product Maximum

Source: Internet
Author: User

1017 Product Maximum

2000 Noip National League popularization Group Noip National League Improvement Group

time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingView Run ResultsTitle Description Description

This year is the "2000--World Mathematics Year" established by the International Mathematical Union, and coincides with the 90 anniversary of the birth of our famous mathematician Mr. Hua. In Mr. Hua's hometown of Jintan, Jiangsu, organized a wonderful mathematical intelligence contest activities, a good friend of your XZ is also fortunate to participate. During the event, the host gives all the participants a title:

There is a number string of length n, requiring the player to use K multiplication sign to divide it into k+1 parts, to find a division, so that this k+1 part of the product can be the largest.

At the same time, in order to help the player to understand test instructions correctly, the moderator also gave the following example:

There is a number string: 312, when N=3,k=1 will have the following two kinds of methods:

1) 3*12=36

2) 31*2=62

At this point, the result that meets the requirements of the question is: 31*2=62

Enter a description Input Description

There are two lines of input to the program:

The first line has a total of 2 natural numbers n,k (6≤n≤40,1≤k≤6)

The second line is a number string with a length of N.

Output description Output Description

The result is displayed on the screen, and the maximum product (a natural number) should be output relative to the input.

Sample input Sample Input

4 2

1231

Sample output Sample Output

62

Data range and Tips Data Size & Hint

Because older, the data is actually relatively small, with a long long can pass

`#include <cstdio> #include <iostream>using namespace std;int n,k;char a[50];int f[50][10];int a1[50];int JS ( int x,int y)//preprocessing, calculates the number of X to J composed of {  int z=0;  for (int i=x;i<=y;i++)    z=z*10+a1[i];  return z;} int main () {scanf ("%d%d", &n,&k), scanf ("%s", &a), for (int i=0;i<=n-1;i++)  a1[i+1]=a[i]-' 0 ';  for (int i=1;i<=n;i++)  f[i][0]=js (1,i), for (Int. i=1;i<=k;i++) for (int.  j=i+1;j<=n;j++) for    (int k1=i;k1<j;k1++)      F[j][i]=max (F[j][i],f[k1][i-1]*js (K1+1,J)),//From the interval (1,j), when multiplication sign is inserted into the K1, the number of previous K1 multiplied by k1+1 to J Maximum cout <<F[N][K];}`

Codevs 1017 Product Maximum

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.