#pragma GCC optmize(2)
#include<bits/stdc++.h>
using namespace std;
__int128 n,m,a[101],mod = 1000007,f[101][101],maxx,mul;
char ch;
__int128 read(){
__int128 reg = 1,x = 0;
char ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-')reg = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
x = x * 10 + (ch - '0');
ch = getchar();
}
return reg * x;
}
void write(__int128 a){
if(a == 0)return;
if(a < 0)putchar('-'),a = -a;
write(a / 10);
putchar(a % 10 + '0');
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
n = read(),m = read();
f[0][0] = 1;
for(__int128 i = 1;i <= n;i++)cin >> ch,a[i] = ch - '0';
for(__int128 i = 1;i <= n;i++){
mul = 0;
for(__int128 j = 0;j <= i;j++)mul = mul * 10 + a[j];
f[i][0] = mul;
for(__int128 j = 1;j <= m;j++){
for(__int128 k = j;k < i;k++){
__int128 mul = 0;
for(__int128 l = k + 1;l <= i;l++)mul = mul * 10 + a[l];
f[i][j] = max(f[i][j] , f[k][j - 1] * mul);
}
}
}
write(f[n][m]);
}
本地运行正确,思路也正确,应该是改成 __int128 后出了问题