#include<iostream>
using namespace std;
int n,m;
int q[11];
long long num;
int res;
void dfs(int u,int key,int sum){
if(u==n | key < 0){
if(key < 0)
res=max(res,sum);
return ;
}
int s=0;
for(int i=u;i<n;i++){
s=s*10 + q[i];
dfs(i+1,key-1,sum*s);
}
}
int main(){
scanf("%d%d",&n,&m);
int b=n;
cin>>num;
while(num){
int x = num%10;
q[--b] = x;
num /= 10;
}
dfs(0,m,1);
printf("%d",res);
}
dfs求解乘积最大(c++实现)
最新推荐文章于 2024-08-10 22:58:42 发布