@[yejingzhi](/user/1037639) 我没写高精度 60pts,但 subtask1 能全过:
```cpp
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define int long long
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
int n, k, dp[41][41], num[41][41];
string s;
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> k >> s, s = ' ' + s;
for (int i = 1; i <= n; i++)for (int j = i; j <= n; j++)num[i][j] = num[i][j - 1] * 10 + s[j] - '0';
for (int i = 1; i <= n; i++)dp[i][0] = num[1][i];
for (int i = 1; i <= n; i++)for (int j = 1; j <= min(k, i - 1); j++)for (int k = j; k <= i - 1; k++)dp[i][j] = max(dp[i][j], dp[k][j - 1] * num[k + 1][i]);
return cout << dp[n][k], 0;
}
```
by __er @ 2023-07-22 22:23:42
@[__er](/user/713955) 可惜#0是60分
by all___right @ 2023-07-22 22:30:04
@[yejingzhi](/user/1037639) 说了没写高精度
by __er @ 2023-07-22 22:30:37
知道
by all___right @ 2023-07-22 22:31:03
放个高精重载运算符的代码改一下变量定义即可
by __er @ 2023-07-22 22:31:04
or等代码
by all___right @ 2023-07-22 22:32:28
高精知识全ERROR,罢工了
by all___right @ 2023-07-22 22:36:03
帖结,代码已做出
```
#include<iostream>
#include<cstring>
#define MAXN 50
template<int __max>
struct exint
{
typedef long long ll;
exint():len(0){std::memset(d,false,sizeof(d));}
exint(ll a):len(0)
{
memset(d,false,sizeof(d));
if(!a)len=1;
else
while(a)d[++len]=a%10,a/=10;
}
friend std::ostream&operator<<(std::ostream&os,exint a)
{
for(int i=a.len;i;--i)os<<a.d[i];
return os;
}
int d[__max],len;
exint operator+(exint b)
{
exint c;
while(c.len<=this->len||c.len<=b.len)
{
c.len++;
c.d[c.len]+=this->d[c.len]+b.d[c.len];
c.d[c.len+1]+=c.d[c.len]/10;
c.d[c.len]%=10;
}
while(!c.d[c.len]&&c.len-1)c.len--;
return c;
}
exint operator*(exint b)
{
exint c;
c.len=this->len+b.len;
for(int i=1;i<=this->len;i++)
for(int j=1;j<=b.len;j++)
c.d[i+j-1]+=this->d[i]*b.d[j],
c.d[i+j]+=c.d[i+j-1]/10,
c.d[i+j-1]%=10;
while(!c.d[c.len]&&c.len-1)c.len--;
return c;
}
bool operator<(exint b)
{
if(this->len<b.len)return true;
if(this->len>b.len)return false;
for(int i=this->len;i;--i)
if(this->d[i]>b.d[i])return false;
else if(this->d[i]<b.d[i])return true;
return false;
}
};
int n,m;
//int mult[MAXN][MAXN],f[MAXN][MAXN];
exint<MAXN>mult[MAXN][MAXN],f[MAXN][MAXN];
char str[MAXN];
using namespace std;
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>str[i];
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
mult[i][j]=mult[i][j-1]*10+(str[j]-'0');
for(int i=1;i<=n;i++)f[i][0]=mult[1][i];
for(int k=1;k<=m;k++)
for(int i=k+1;i<=n;i++)
for(int j=k;j<i;j++)
if(f[i][k]<f[j][k-1]*mult[j+1][i])
f[i][k]=f[j][k-1]*mult[j+1][i];
cout<<f[n][m]<<endl;
}
```
by all___right @ 2023-07-23 09:01:57
?
by 15167987933yy @ 2023-07-29 16:58:56