---
# System prepended metadata

title: Code 1 lqdoj/lastzerohsg

---

# Code 1 lqdoj/lastzerohsg
```cpp=
#include <bits/stdc++.h>
 
using namespace std;
const int maxn=1e5+5;
const long long inf = 1e18+7;
 
long long a[105];
long long f[105][105];
long long p2[105],p5[105];
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    int n,k;
    cin>>n>>k;
    long long m5=0;
    for(int i = 1 ; i<= n ; i++)
    {
        cin>>a[i];
        long long check=a[i];
        long long num2=0,num5=0;
        while(check%2==0)
        {
            num2++;
            check/=2;
        }
        p2[i]=num2;
        while(check%5==0)
        {
            num5++;
            check/=5;
        }
        p5[i]=num5;
        m5+=num5;
    }
    for(int x = 1; x <=n ; x++)
    {
        for(int i = k ; i>=1 ; i--)
        {
            for(long long j = 0; j<=m5;j++)
            {
                f[i][j]=max(f[i][j],f[i-1][j-p5[x]]+p2[x]);
            }
        }
    }
    long long ans=0;
    for(long long i = 0; i<=m5;i++)
    {
        ans=max(ans,min(i,f[k][i]));
    }
    cout<<ans;
    return 0;
}
```

{%hackmd AfkxoUIBRFKjyvpLo0GIFg %}