设dp[i][j][k]表示前i个数中选j个并且因子含有k个2的能获得的最多的5的个数

则dp[i][j][k]=max(dp[i-1][j][k],dp[i-1][j-1][k-cnt2]+cnt5)

滚掉一维

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
int n, m, allcnt, dp[205][12005], cnt2, cnt5, ans;
long long uu;
int main(){
cin>>n>>m;
memset(dp, 0x80, sizeof(dp));
dp[0][0] = 0;
for(int i=1; i<=n; i++){
cin>>uu;
cnt2 = cnt5 = 0;
while(uu%2==0){
cnt2++;
uu /= 2;
}
while(uu%5==0){
cnt5++;
uu /= 5;
}
allcnt += cnt2;
for(int j=min(m,i); j>=1; j--)
for(int k=allcnt; k>=cnt2; k--)
dp[j][k] = max(dp[j-1][k-cnt2]+cnt5, dp[j][k]);
}
for(int i=1; i<=allcnt; i++)
ans = max(ans, min(dp[m][i], i));
cout<<ans<<endl;
return 0;
}

cf837d Round Subset的更多相关文章

  1. CF837D Round Subset 动态规划

    开始的时候数据范围算错了~ 我以为整个序列 2 和 5 的个数都不超过 70 ~ 一个非常水的 dp code: #include <bits/stdc++.h> #define M 75 ...

  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(dp)

    837D - Round Subset 思路:dp.0是由2*5产生的. ①dp[i][j]表示选i个数,因子2的个数为j时因子5的个数. 状态转移方程:dp[i][j]=max(dp[i][j],d ...

  4. D - Round Subset codeforces837d

    D - Round Subset 思路:背包: 代码: #include <cstdio> #include <cstring> #include <iostream&g ...

  5. Codeforces 837D Round Subset(背包)

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

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

  7. [CF837D]Round Subset_动态规划

    Round Subset 题目链接:http://codeforces.com/problemset/problem/837/D 数据范围:略. 题解: $dp$比较显然. 但是卡空间,有两种方法: ...

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

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

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

随机推荐

  1. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) A

    Description Bear Limak wants to become the largest of bears, or at least to become larger than his b ...

  2. 模拟+贪心 URAL 1804 The Machinegunners in a Playoff

    题目传送门 题意:A队和B队踢球,已知一场比赛A和B的得分情况,问A最小再得几分就能胜利还有最多能的几分还能给B队一丝翻盘的希望.规则如下: 1. 总分数相等的情况下,在客场得分高的获胜,如果还相等, ...

  3. 1-10super和this关键字

    什么是super? super代表的是当前子类对象中的父类型特征. 什么时候使用super? 子类和父类中都有某个数据,例如,子类和父类中都有name这个属性.如果要再子类中访问父类中的name属性, ...

  4. h5-24-百度地图-地址解析

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. Appium + python自动化 - 启动app

    各种百度将Appium + python的环境搭建好后,开启移动app自动化的探索(基于Android),首先来记录下如何启动待测的app吧! 如何启动app呢?首先要获取包名,然后获取launche ...

  6. CentOS 7.2最小化安装没有ifconfig命令,使用yum provides ifconfig找不到相关的包

    [root@sishen yum.repos.d]# yum provides ifconfig Loaded plugins: fastestmirror Loading mirror speeds ...

  7. PowerShell和Bash的介绍

    PowerShell是运行在windows平台的脚本,而Bash是运行在linux平台的脚本 现在bash能做的事情,PowerShell也能做,PowerShell的强大之处是它可以管理window ...

  8. asp.net MVC 错误信息“没有为该对象定义无参数的构造函数”请求各位大神帮忙!

    在做一个登录的功能,没有用MVC自己生成的identity代码,仿照别人的代码写出了以后出现错误. 错误信息如下: 代码如下: 求各位asp.net大神支招,网上找了资料最终也没解决这个问题.

  9. poj2377 Bad Cowtractors

    思路: 最大生成树. 实现: #include <iostream> #include <cstdio> #include <vector> #include &l ...

  10. [BZOJ2761][JLOI2011]不重复数字 暴力

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2761 直接暴力. #include<cstdio> #include<c ...