D - Round Subset

思路:背包;

代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
ll n,m,dp[][],tmp,p2,p5,pos,sum,ans;
int main()
{
//freopen("data.txt","r",stdin);
scanf("%lld%lld",&n,&m);
memset(dp,-0x7f,sizeof(dp)),dp[][]=;;
for(ll i=;i<=n;i++)
{
cin>>tmp,pos=tmp,p5=,p2=;
while(pos%==) pos/=,p2++;
while(tmp%==) tmp/=,p5++;
sum+=p5;
for(ll v=min(i,m);v>=;v--)
for(ll e=sum;e>=p5;e--) dp[v][e]=max(dp[v][e],dp[v-][e-p5]+p2);
}
for(ll i=;i<=sum;i++) ans=max(ans,min(i,dp[m][i]));
cout<<ans;
return ;
}

D - Round Subset codeforces837d的更多相关文章

  1. 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 ...

  2. 【动态规划】Round Subset

    CF837D. Round Subset Let's call the roundness of the number the number of zeros to which it ends. Yo ...

  3. Codeforces 837D Round Subset(背包)

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

  4. Codefroces Educational Round 26 837 D. Round Subset

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

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

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

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

  7. Codeforces 837D Round Subset - 动态规划 - 数论

    Let's call the roundness of the number the number of zeros to which it ends. You have an array of n ...

  8. 【Codeforces 837D】Round Subset

    http://codeforces.com/contest/837/problem/D 分解质因数,即第i个数的因子2的个数为c2[i],因子5的个数为c5[i],末尾零的个数就是min{Σc2[i] ...

  9. Educational Codeforces Round 26-D. Round Subset

    题目大意:给你n个数字(小于1e18),从n个数中取k个数字相乘,使其后缀0最多,问你后缀0最多是多少. 知道得用三维的dp[ i ] [ j ] [ k ]  第一维表示用到第 i 个数为止,j 表 ...

随机推荐

  1. Java 守护线程概述

    原文出处: 朱小厮 Java的线程分为两种:User Thread(用户线程).DaemonThread(守护线程). 只要当前JVM实例中尚存任何一个非守护线程没有结束,守护线程就全部工作:只有当最 ...

  2. CAAnimation保持动画结束时的效果

    配置动画时,加上一下两句 animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards;

  3. Metrics.Net实践(2)在WEB中应用度量

    Gauges 可以画出Http Request执行时间的波形图: actionInfo表示MVC中的Action,即按照action类型来分组 Metric.Context(this.actionIn ...

  4. [转载]IIS6.0开启WOFF/SVG文件支持

    http://www.bao21.com/120.html http://stackoverflow.com/questions/18369036/bootstrap-3-glyphicons-not ...

  5. Spark MLlib使用有感

    这些天在公司里面做文本分析的任务,我跟着玻哥一起做,先研究了算法的可行度,最后决定使用Google的Word2Vector和LDA算法来对文本进行分析.之前因为看过一些Spark的东西,所以准备瞄准M ...

  6. Shell编程之运算符和环境变量配置文件

    一.shell运算符:    declare命令:         declare    -i 变量名     #声明变量        eg. movie[o]=dzp     #定义数组      ...

  7. python Linux flask uwsgi nginx 在centos7.3部署

    0.直接上uwsgi和nginx安装命令 linux 安装uwsgi yum groupinstall "Development tools" yum install zlib-d ...

  8. Ubuntu 14.04 Nvidia显卡驱动安装及设置

    更换主板修复grub 引导后,无法从Nvidia进入系统(光标闪烁), 可能是显卡驱动出了问题. 1. 进入BIOS设置, 从集成显卡进入系统 将显示器连接到集显的VGI口, 并在BIOS中设置用集显 ...

  9. tomcat集群及session共享

    一般来说,java web app主要用作两个领域: 1.api.api一般是无状态的,所以无需考虑session共享的问题 2.传统web应用和网站,如crm,oa,erp,b2c,bbs等.尤其b ...

  10. 10种CSS3实现的Loading效果

    原文链接:http://www.cnblogs.com/jr1993/p/4622039.html 第一种效果: 代码如下: <div class="loading"> ...