# Educational Codeforces Round 26 D Round Subset

D. Round Subset
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Let's call the roundness of the number the number of zeros to which it ends.

You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible.

Input

The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n).

The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 1018).

Output

Print maximal roundness of product of the chosen subset of length k.

Examples
input
3 2
50 4 20

output
3

input
5 3
15 16 3 25 9

output
3

input
3 3
9 77 13

output
0

Note

In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2[4, 20] — product 80roundness 1,[50, 20] — product 1000roundness 3.

In the second example subset [15, 16, 25] has product 6000roundness 3.

In the third example all subsets has product with roundness 0.

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long

using namespace std;
const int maxn=205;
ll dp[maxn][60*maxn];
ll map[maxn],ans2;

ll judge(ll x)
{
ll ans1=0;
ll temp=x;
ans2=0;
while(temp)
{
if(x%2==0)
{
ans1++;
x/=2;
}
else
break;
}
while(temp)
{
if(x%5==0)
{
ans2++;
x/=5;
}
else
break;
}

return ans1;
}

int main()
{
ll n,k,i,j,x,ans1,l;
while(cin>>n>>k)
{
memset(dp,-0x3f3f3f3f,sizeof(dp));
dp[0][0]=0;

for(i=0;i<n;i++)
{
cin>>x;
ans1=judge(x);
for(j=k;j>=1;j--)
{
for(l=ans1;l<60*maxn;l++)
{
dp[j][l]=max(dp[j][l],dp[j-1][l-ans1]+ans2);
}
}
}
ll ans=0;
for(i=1;i<60*maxn;i++)
{
ans=max(ans,min(i,dp[k][i]));
}
cout<<ans<<endl;
}
return 0;
}

#### Educational Codeforces Round 46

2018-06-28 17:53:23

#### Educational Codeforces Round 45

2018-06-11 20:32:39

#### Educational Codeforces Round 26

2017-08-04 14:21:47

#### Educational Codeforces Round 36

2018-01-16 12:45:18

#### Educational Codeforces Round 26 D

2017-08-05 00:44:12

#### cf Educational Codeforces Round 26 D. Round Subset

2017-08-10 11:13:19

#### Educational Codeforces Round 26 D. Round Subset 滚动数组优化DP

2017-08-07 11:04:47

#### Educational Codeforces Round 45 题解

2018-06-11 18:06:16

#### Educational Codeforces Round 26总结

2017-08-04 02:23:52

#### Educational Codeforces Round 26 E

2017-08-05 10:59:42