求助...只过了样例...
查看原帖
求助...只过了样例...
307612
Brunhild楼主2020/7/31 19:20

RT

#include <bits/stdc++.h>
using namespace std;
int n,t;
int z[41];
int p[10000][10000],dp[10000][10000];
char f[41];
int main(){
	cin>>n>>t;
	for (int i=1;i<=n;++i) cin>>f[i];
	for (int i=1;i<=n;++i) z[i]=f[i]-'0';
	for (int i=1;i<=n;i++){
		for (int j=i;j<=n;j++) p[i][j]=p[i][j-1]*10+z[j];
	}
	for (int i=1;i<=t+1;i++){
		for (int j=i;j<=n;j++){
			dp[i][j]=1;
			for (int k=i-1;k<=j-1;k++) dp[i][j]=max(dp[i-1][k]*p[k+1][j],dp[i][j]);
		}
	}
	cout<<dp[t+1][n];
}

在线等,急...

2020/7/31 19:20
加载中...