/*
CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26
题意:
选k个数相乘让末尾0最多
分析:
第i个数字有a[i]个2, b[i] 个5
以其中一维作体积另一维作价值01背包即可
*/
#include <bits/stdc++.h>
using namespace std;
int dp[205][20005];
int get2(long long x)
{
int s = 0;
while (x % 2 == 0) s++, x /= 2;
return s;
}
int get5(long long x)
{
int s = 0;
while (x % 5 == 0) s++, x /= 5;
return s;
}
int n, k;
int main()
{
scanf("%d%d", &n, &k);
memset(dp, -1, sizeof(dp));
dp[0][0] = 0;
for (int i = 1; i <= n; i++)
{
long long x; scanf("%lld", &x);
int a = get2(x);
int b = get5(x);
for (int j = k; j >= 1; j--)
for (int p = a; p <= 20000; p++)
if (dp[j-1][p-a] != -1)
dp[j][p] = max(dp[j][p], dp[j-1][p-a] + b);
}
int ans = 0;
for (int i = 1; i <= 20000; i++)
if (dp[k][i] != -1)
ans = max(ans, min(i, dp[k][i]));
printf("%d\n", ans);
}

  

CodeForces 837D - Round Subset | Educational Codeforces Round 26的更多相关文章

  1. CodeForces 837F - Prefix Sums | Educational Codeforces Round 26

    按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...

  2. Educational Codeforces Round 26 [ D. Round Subset ] [ E. Vasya's Function ] [ F. Prefix Sums ]

    PROBLEM D - Round Subset 题 OvO http://codeforces.com/contest/837/problem/D 837D 解 DP, dp[i][j]代表已经选择 ...

  3. Educational Codeforces Round 26

    Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...

  4. CodeForces - 837E - Vasya's Function | Educational Codeforces Round 26

    /* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f( ...

  5. Codeforces 837D - Round Subset(dp)

    837D - Round Subset 思路:dp.0是由2*5产生的. ①dp[i][j]表示选i个数,因子2的个数为j时因子5的个数. 状态转移方程:dp[i][j]=max(dp[i][j],d ...

  6. Educational Codeforces Round 26 D dp

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

  7. Codeforces 837D Round Subset(背包)

    题目链接  Round Subset 题意  在n个数中选择k个数,求这k个数乘积末尾0个数的最大值. 首先我们预处理出每个数5的因子个数c[i]和2的因子个数d[i] 然后就可以背包了. 设f[i] ...

  8. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  9. Educational Codeforces Round 60 (Rated for Div. 2) 题解

    Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...

随机推荐

  1. varnish 子程序流程

    VCL中主要动作: pass:当一个请求被pass后,这个请求将通过varnish转发到后端服务器,该请求不会被缓存,后续的请求仍然通过Varnish处理.pass可以放在vcl_recv 和vcl_ ...

  2. Lua模除运算的大坑

    问题 对负数进行模除运算遇到的坑,Lua的%运算与C++的%有差异 实践 结论 Lua%运算的基本公式 a % b = a - ( ( a // b ) * b ) 1.在C,C++中 %运算符的取整 ...

  3. Asp.net core 学习笔记 QR code and Barcode

    QR code 和 Barcode 经常会使用到. Java 阵营有著名的 zxing https://github.com/zxing/zxing .Net 有对接它的 port https://g ...

  4. JAVA生成验证码代码

    生成base64格式图片验证码 /** * 验证码的候选内容 */ private char codeSequence[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', ...

  5. centos中拉取postgre

    新搭建好的linux服务器环境,docker也配置好了. 第一步,下载postgre docker pull postgres:11 这里的版本号自己按照自己的需要来获取. 然而实际上没那么顺利,直接 ...

  6. bash shell脚本之使用expr运算

    bash shell中的数学运算 cat test7: #!/bin/bash # An example of using the expr command var1= var2= var3=`exp ...

  7. IDEA GIT 忽略文件

    1.装插件 .igore 2.新建忽略文件格式 3.编辑忽略后缀文件 可以是文件夹 也可以是 具体文件类型

  8. go语言入门(10)并发编程

    1,概述 1.1并发和并行 并行(parallel):指在同一时刻,有多条指令在多个处理器上同时执行. 并发(concurrency):指在同一时刻只能有一条指令执行,但多个进程指令被快速的轮换执行, ...

  9. JPA的API介绍、工具类抽取

    1.Persistence对象 Persistence对象主要作用是用于获取EntityManagerFactory对象的 .通过调用该类的createEntityManagerFactory静态方法 ...

  10. const成员函数和const对象

    从成员函数说起 在说const成员函数之前,先说一下普通成员函数,其实每个成员函数都有一个隐形的入参:T *const this. int getValue(T *const this) { retu ...