#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=205;
const int M=1e5+10;
int t,n,k,a[N];
int dp[N][M];
pair<int,int> p[N];
int32_t main(){
memset(dp,-0x3f,sizeof dp);
scanf("%lld%lld",&n,&k);
int ans=0;
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
int cnt=0;
int now=a[i],cnt2=0,cnt5=0;
while(now%2==0){now=now/2;cnt2++;}
while(now%5==0){now=now/5;cnt5++;}
p[i]={cnt2,cnt5};
}
dp[0][0]=0;
for(int i=1;i<=n;i++){
for(int j=min(k,i);j>=1;j--){
for(int l=15000;l>=0;l--){
dp[j][l]=max(dp[j-1][l],dp[j][l]);
if(l>=p[i].first){
dp[j][l]=max(dp[j-1][l-p[i].first]+p[i].second,dp[j][l]);
}
// cout<<j<<" "<<l<<" "<<dp[j][l]<<endl;
}
}
}
for(int i=0;i<15000;i++){
ans=max(ans,min(i,dp[k][i]));
}
cout<<ans<<endl;
}
Educational Codeforces Round 26 D. Round Subset(背包dp
于 2022-01-23 17:07:48 首次发布