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

我以为整个序列 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. Python基础 — 数据类型转换

    Python 数据类型转换 有时候,我们需要对数据内置的内心进行转换,数据类型的转换,你只需要将数据类型作为函数名即可. 以下几个内置的函数可以执行数据类型之间的转换,这些函数返回一个新的对象,表示转 ...

  2. WUSTOJ 1307: 校门外的树(Java)

    题目链接:

  3. VMware Workstation Pro 15 序列号

    VMware Workstation Pro 15 序列号: GA70H-8TYE2-H886P-04YZC-YVA84 YG5H2-ANZ0H-M8ERY-TXZZZ-YKRV8 UG5J2-0ME ...

  4. Codeforces-975C - Valhalla Siege 前缀和 思维

    C. Valhalla Siege time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  5. C#-Json-抽象类的反序列化

    引用: using System; using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Lin ...

  6. windows环境下如何搭建Consul+Ocelot

    下面的是markdown格式的文档,懒得排版了,有兴趣的话可以去github上看,有源码 Github:https://github.com/yuchengao0721/Consul-Ocelot.g ...

  7. centos6克隆虚拟机后,网络无法访问和启动

    使用vmware安装centos6虚拟机时, 克隆虚拟机后无法访问网络. 原因是:产生了重复的网卡信息** 克隆后在70-persistent-net.rules文件中会多一行网卡信息,把第一行网卡信 ...

  8. How to : SAP PI Cache Refresh

    Requirement : Identify various tools/resources available to perform SAP PI Cache refresh . Please no ...

  9. iOS音频学习笔记三:音频会话管理

    ​      使用Audio Session API ,可以指定App需要的音频行为,比如,当播放音频时,使得其他应用App静音或者混和在一起,也可以指定当App的音频被中断(例如被电话)时的行为,还 ...

  10. pygame安装遇到的坑

    坑一:python版本冲突,电脑同时安装多个版本的python,由于每个都是python.exe,cmd命令窗口输入的python不一定是你想要的版本,所以最好还是安装单个版本即可. 坑二:由于电脑安 ...