开始的时候数据范围算错了~

我以为整个序列 2 和 5 的个数都不超过 70 ~

一个非常水的 dp

code:

#include <bits/stdc++.h>
#define M 75
#define N 201
#define LL long long
using namespace std;
void setIO(string s)
{
string in=s+".in";
string out=s+".out";
freopen(in.c_str(),"r",stdin);
freopen(out.c_str(),"w",stdout);
}
int f[N][6800];
struct node
{
int t2,t5;
}t[N];
int main()
{
// setIO("dynamic-programming");
int i,j,n,k;
scanf("%d%d",&n,&k);
memset(f,-0x3f,sizeof(f));
f[0][0]=0;
for(i=1;i<=n;++i)
{
LL x;
scanf("%lld",&x);
while(x%2==0) ++t[i].t2,x/=2;
while(x%5==0) ++t[i].t5,x/=5;
}
for(i=1;i<=n;++i)
{
for(j=i;j>=1;--j)
{
for(int p=6700;p>=t[i].t5;--p)
{
f[j][p]=max(f[j][p], f[j-1][p-t[i].t5]+t[i].t2);
}
}
}
int best=0;
for(i=1;i<=k;++i)
{
for(j=1;j<=6700;++j)
{
best=max(best,min(j, f[i][j]));
}
}
printf("%d\n",best);
return 0;
}

  

CF837D Round Subset 动态规划的更多相关文章

  1. [CF837D]Round Subset_动态规划

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

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

  3. cf837d Round Subset

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

  4. 【动态规划】Round Subset

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

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

  6. D - Round Subset codeforces837d

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

  7. Codeforces 837D Round Subset(背包)

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

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

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

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

随机推荐

  1. binlogserver搭建

    在MySQL 5.7.x版本中,mysqlbinlog工具解析任何一个本地的binlog或relay log时,都不会在mysqlbinlog命令执行结束时追加rollback语句, 但在MySQL ...

  2. SQL高级教程

    一.top子句 top子句用于规定要返回的记录的数目 并非所有数据库系统都支持top子句 # sqlserver SELECT TOP number|percent column_name(s) FR ...

  3. hoj 棋盘问题 状压入个门

    大概题意是:有一个n*m的棋盘,在这个棋盘里边放k个旗子,要求每一行每一列都不能存在一对旗子相邻,问最后总共的方案数. 我们先来考虑个简单的,假如说只有一行,要求在这一行里边填充k个旗子,要求任意两个 ...

  4. typeAliasesPackage 属性的作用

    applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...

  5. 什么叫工业4.0,这篇接地气的文章终于讲懂了(ZT)

    原地址:https://www.cnblogs.com/namei/p/6110382.html 笔者早年从事过工业自动化行业,后来去了几个城市,讲过<工业互联网与工业文明史>这门课,以至 ...

  6. Python3标准库使用样例

    原:https://doughellmann.com/blog/the-python-3-standard-library-by-example/the-python-3-standard-libra ...

  7. Android Studio 生成 keystore 签名文件

    Android Studio 生成 keystore 签名文件 常见 SSL 证书格式 : .DER .CER,文件是二进制格式,只保存证书,不保存私钥. .PEM,一般是文本格式,可保存证书,可保存 ...

  8. snort_inline

    snort_inline Link   http://snort-inline.sourceforge.net/oldhome.html What is snort_inline? snort_inl ...

  9. python入门-windows下anaconda环境搭建

    1. anaconda下载 根据根据自己系统下载32位还是64位,还有版本 python3.6——64bit python3.6——32bit python2.7——64bit python2.7—— ...

  10. mysql日期模糊查找的方法

    Mysql模糊查询有以下三种方法: 1.Convert转成日期时间型,在用Like查询.select * from table1 where convert(date,DATETIME) like ' ...