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. Git7:使用Gitlab管理远程仓库

    目录 1.安装 2.gitlab基本配置 3.gitlab的邮件配置 3.1.使用本地的postfix发送邮件 3.2.使用邮件发送模板 3.3.使用腾讯企业邮箱配置发送邮件 3.4.使用163邮箱来 ...

  2. vue学习记录

    vue中常用的指令 v-model 双向数据绑定,一般用于表单元素 v-for 对数组或对象进行循环操作,使用的是v-for <!-- 普通循环 --><li v-for=" ...

  3. vue 混入的理解

  4. snprintf()解析

    snprintf(ssid_mac,sizeof(ssid_mac),"%s_%02X%02X",ssid,macval[4],macval[5]); ssid_mac = ssi ...

  5. 转:zookeeper中Watcher和Notifications

    转自:http://www.tuicool.com/articles/B7FRzm 传统polling远程service服务 传统远程的service往往是这样服务的,服务提供者在远程service注 ...

  6. nodejs出现events.js:72中抛出错误 Error: listen EADDRINUSE

    <pre>events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoExce ...

  7. Xilinx Altera FPGA中的逻辑资源(Slices VS LE)比较

    前言 经常有朋友会问我,“我这个方案是用A家的FPGA还是X家的FPGA呢?他们的容量够不够呢?他们的容量怎么比较呢?”当然,在大部分时候,我在给客户做设计的时候,直接会用到最高容量的产品,因为我们的 ...

  8. 一个愚蠢的python逻辑语法错误

    这个事情再次佐证了一个莫名其妙的现象背后一定会有一个愚蠢到无以复加的错误的真理. 写python单元测试的时候发现一个莫名其妙的问题: def xmlStandander(self,s): retur ...

  9. 训练赛第一场D题

    解题报告:一开始不知道ATA的意思,后来才知道原来是转置矩阵乘以原来的矩阵.这题说起来比较麻烦就不说了,直接上代码: #include<cstdio> #include<cstrin ...

  10. PHP autoload自动加载机制

    原文地址: http://www.jb51.net/article/31399.htm 一直不是很明白__autoload()和spl_autoload_register()到底有什么不同,找到了一个 ...