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 80, roundness 1, [50, 20] — product 1000, roundness 3.

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

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

题意:给你n个数 取出k个 ans 为k个数乘积的结果的末尾的零的个数

题解:dp[i][j] 选择i个数  因子5的个数为j  的2的个数为 dp[i][j]

 #pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
#define LL long long
#define mod 1000000007
using namespace std;
int n,k;
LL a[];
LL dp[][];
struct node{
int x,y;
}N[];
int main()
{
memset(dp,,sizeof(dp));
scanf("%d %d",&n,&k);
for(int i=; i<=n; i++)
scanf("%I64d",&a[i]);
for(int i=;i<=k;i++)
for(int e=;e<=;e++)
dp[i][e]=-1e9;
dp[][]=;
LL zha;
int now=,xx=;
for(int i=; i<=n; i++){
zha=a[i];
now=;
xx=;
while(zha>){
if(zha%!=)
break;
zha/=;
now++;
}
zha=a[i];
while(zha>){
if(zha%!=)
break;
zha/=;
xx++;
}
N[i].x=now;
N[i].y=xx;
}
for(int i=;i<=n;i++){
for(int j=k-;j>=;j--){
for(int e=;e<=;e++)
dp[j+][e+N[i].x]=max(dp[j+][e+N[i].x],dp[j][e]+N[i].y);
}
}
LL maxn=;
for(LL e=;e<=;e++)
maxn=max(maxn,min(dp[k][e],e));
printf("%I64d\n",maxn);
return ;
}

Educational Codeforces Round 26 D dp的更多相关文章

  1. Educational Codeforces Round 26

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

  2. CodeForces 837D - Round Subset | Educational Codeforces Round 26

    /* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...

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

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

  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. 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]代表已经选择 ...

  6. codeforces Educational Codeforces Round 16-E(DP)

    题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍 ...

  7. Educational Codeforces Round 60 D dp + 矩阵快速幂

    https://codeforces.com/contest/1117/problem/D 题意 有n个特殊宝石(n<=1e18),每个特殊宝石可以分解成m个普通宝石(m<=100),问组 ...

  8. Educational Codeforces Round 15 A dp

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. Educational Codeforces Round 26 B,C

    B. Flag of Berland 链接:http://codeforces.com/contest/837/problem/B 思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出 ...

随机推荐

  1. kali获得windows的shell后乱码

    输入 chcp 65001

  2. passwd命令详解

    基础命令学习目录首页 passwd命令用于设置用户的认证信息,包括用户密码.密码过期时间等.系统管理者则能用它管理系统用户的密码.只有管理者可以指定用户名称,一般用户只能变更自己的密码. 语法 pas ...

  3. 【请仔细核对Git地址】关于代码量排名的说明

    1.截至2017年3月14日,1623班级代码统计情况如下: 2.代码量排名是基于码云的git地址统计的,请大家仔细核对以下个人地址,如有问题请及时联系我. 20162301 20162302 201 ...

  4. 第二阶段每日站立会议Forth Day

    昨天对于程序中的字体显示进行细化修改,使界面更美观 今天准备继续调试手机界面 遇到的问题:上几次Tomcat运行正常,今天突然出现问题,Tomcat服务可以打开,但是无法连接到数据库

  5. php----函数大全

    字符串函数 数组函数 数学函数

  6. 听说 —— beta冲刺总结

    听说 -- beta冲刺总结 beta冲刺成员名单 姓名 学号 负责方向 个人主页 周龙荣 031402543 前端页面.跳转 http://www.cnblogs.com/ZHOULR/ 李家鹏 0 ...

  7. 小学四则运算练习(JAVA编写)

    源码在Github的仓库主页链接地址:https://github.com/rucr9/rucr 看到这个题目,大概很多人会发出“切,这也太简单了吧!有必要小题大做?”的感叹!是的,仅仅作为一道数学运 ...

  8. 如何提高cxgrid的刷新速度

    如果View的类型是cxGridDBTableView: 1.cxGrid.DisableControls;cxGrid.EnableControls; 如仍觉得慢,可以把 cxGrid1DBTabl ...

  9. 学习mysql触发器遇到的问题

    在 mysql.exe 下面运行的.如果是的话, 可能是需要加一个 定义 DELIMITER // 意思是告诉 mysql , 遇到 // 符号以后, 才认为语句结束了. 否则 mysql 遇到 分号 ...

  10. ci钩子

    钩子 - 扩展框架核心 CodeIgniter 的钩子特性提供了一种方法来修改框架的内部运作流程,而无需修改 核心文件.CodeIgniter 的运行遵循着一个特定的流程,你可以参考这个页面的 应用程 ...