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. BugPhobia回顾篇章:团队Alpha阶段工作分析

    0x00:序言 1 universe, 9 planets, 204 countries,809 islands, 7 seas, and i had the privilege to meet yo ...

  2. 20135231 JAVA实验报告三:敏捷开发与XP实践

    ---恢复内容开始--- JAVA实验报告三:敏捷开发与XP实践 20135231 何佳 实验内容 1. XP基础 2. XP核心实践 3. 相关工具 实验要求 1.没有Linux基础的同学建议先学习 ...

  3. C#中周,月,第几周,周开始结束时间de方法总结

    1.c#获取当前时间是本年的第几周,本月的第几周 private static int getWeekNumInMonth(DateTime daytime) { int dayInMonth = d ...

  4. 第二阶段Sprint1

    昨天:进行第二阶段第一次站立会议,讨论冲刺阶段,目标,任务认领 今天:实现视频录制,共享平台的视频下载和上传 遇到的问题:调手机摄像头没问题,共享平台怎么办

  5. Teamwork(The eighth day of the team)

    在经过算是蛮艰辛的努力后吧,我们终于有了一点点成果.虽然还离理想中的蛮遥远的,但是我们相信,虽然我们走得很慢,但是我们一直都会坚持前进.

  6. Visual Studio 中配置openCV问题

    1. 首先强调一点:VS与openCV的版本对应问题,一般而言,openCV对于VS采用向下的支持方式: vc6 -> VS6.0 vc7.0 -> VS2002 vc7.1 -> ...

  7. iOS- Exception Type: 00000020:什么是看门狗机制

      1.前言    前几天我们项目闪退之后遇到的一个Crash,之后逛了许多论坛,博客都没有找到满意的回复  在自己做了深入的研究之后,对iOS的看门狗机制有了一个基本的了解  而有很多奇怪的Cras ...

  8. [2017BUAA软工]个人项目心得体会:数独

    心得体会 回顾此次个人项目,感受比较复杂,最明显的一点是--累!代码编写.单元测试.代码覆盖.性能优化,环环相扣,有种从作业发布开始就一直在赶DDL的感觉,但是很充实,也学习到和体验了很多东西.最令人 ...

  9. 探秘SpringAop(一)_介绍以及使用详解

    常用的编程范式 AOP 是什么 是一种编程方式,不是编程语言 解决特定问题,不能解决所有的问题 OOP的补充,不是代替 AOP 初衷 DRY: Don't repeat yourself(代码重复) ...

  10. js小功能记录

    个人日常中遇到的js小功能记录,方便查看. /** * 判断是否包含字符串某字符串 * @param {[type]} str [被检测的字符串] * @param {[type]} substr [ ...