/*
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. ThreadLocal,Lock的事儿

    ThreadLocal作用 防止线程间的干扰 public interface Sequence { int getNumber(); } public class ClientThread exte ...

  2. php分页思路

    <?php class page{ public $nowPage=1; public $perPage=10; public $showPage=10; public $totalPage; ...

  3. python — 装饰器、迭代器

    目录 1 装饰器 2 迭代器 3 可迭代对象 1 装饰器 1.1目的.应用场景: 目的: 在不改变原函数内部代码的基础上,在函数执行前后自定义功能. 应用场景: 想要为函数扩展功能时,可以选择用装饰器 ...

  4. Redis学习存档(1)——安装

    以虚拟机中的Linux系统(CentOS 6.5)中安装Redis为例 一.下载Redis 使用wget进行下载,可能部分系统不带wget命令,则yum下载即可 yum -y install wget ...

  5. TCP协议探究(三):RTT、滑动窗口和阻塞处理

    1 RTT算法 1.1 概述 上一节说了重传机制需要设置一个重传超时值(RTO,Retransmission TimeOut),RTO设长了,重发太慢:设短了,可能导致包没有丢,就重发了,可能导致雪崩 ...

  6. 作业1:java虚拟机内存模型图示

    看了很多篇文章,整理成一幅图,但仍然有许多不解的地方,以后再接着完善,哪位大神看到不正确的地方,请指出,谢谢.

  7. MVC授权不通过之后不执行任何自定义ActionFilter

    如下一个Action [Authorize] [F1]//自定义过滤器,继承自ActionFilter public ActionResult Index() { return View(); } 如 ...

  8. mysql 添加grant权限

    GRANT USAGE ON *.* TO 'xxxx'@'x.%.%.%' WITH GRANT OPTION;

  9. javaweb开发技术--监听器

    监听器定义:是指专门用于其他对象身上发生的事件或状态改变进行监听和相应的处理的对象,当被监视的对象发生变化时立即采取相应的行动. web监听器的定义:servlet规范中定义的一种特殊类.用于监听Se ...

  10. DX使用随记--TabControl

    1. 关闭TabControl选项卡: Private Sub TabControl_Main_CloseButtonClick(sender As Object, e As EventArgs) H ...