CF837D Round Subset 动态规划
开始的时候数据范围算错了~
我以为整个序列 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 动态规划的更多相关文章
- [CF837D]Round Subset_动态规划
Round Subset 题目链接:http://codeforces.com/problemset/problem/837/D 数据范围:略. 题解: $dp$比较显然. 但是卡空间,有两种方法: ...
- 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 ...
- 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 ...
- 【动态规划】Round Subset
CF837D. Round Subset Let's call the roundness of the number the number of zeros to which it ends. Yo ...
- 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 ...
- D - Round Subset codeforces837d
D - Round Subset 思路:背包: 代码: #include <cstdio> #include <cstring> #include <iostream&g ...
- Codeforces 837D Round Subset(背包)
题目链接 Round Subset 题意 在n个数中选择k个数,求这k个数乘积末尾0个数的最大值. 首先我们预处理出每个数5的因子个数c[i]和2的因子个数d[i] 然后就可以背包了. 设f[i] ...
- 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 ...
- CodeForces 837D - Round Subset | Educational Codeforces Round 26
/* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...
随机推荐
- 《MySQL数据库从入门到精通》 高级运维人才的必备书籍
众所周知,每年就业市场都会迎来千万量级的高校毕业生,然而企业招工难和毕业生就业难的矛盾却一直没有得到很好地解决.究其原因,主要矛盾还是在于传统的学历教育与企业实际需求相脱节.为了杜绝高校毕业生求职时常 ...
- hadoop 完全分布式搭建总结
完全分布式--------------- 1.配置文件 [core-site.xml] hdfs 地址 fs.defaultFS=hdfs://s129:8020/ [hdfs-site.xml] 副 ...
- Hibernate常用api以及增删改查
一 .API的定义 所谓的API全称就是(Application Programming Interface,应用程序编程接口).就是类库对外提供的接口.类.枚举.注解等元素. 如:JDK API ...
- js入门之内置对象Date
一. Date对象 Math和Date对象的区别 Math对象和Date对象的区别 Math不是一个构造函数,里面提供的是静态成员 Date是一个构造函数 首先要通过new Date() 来创建日期实 ...
- sql server动态分页
USE RYPlatformManagerDB GO SET ANSI_NULLS, QUOTED_IDENTIFIER ON GO CREATE Proc [dbo].[WEB_PageView] ...
- Vue路由嵌套和命名视图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- ping IP 带时间戳循环显示并写入日志(windos版+linux版)
在工作中,判断网络是否通畅,首选命令就是ping,但有时候我们需要持续ping一个或多个地址时,需要加 -t 即可,但有时候需要在ping的时候加入时间戳并把ping记录写入到日志里面,方法如下: w ...
- 记录--linux下mysql数据库问题
本次主要记录一下linux下mysql数据库的一些问题,也是之前经常用到的知识,这里简单总结一些问题,方便自己以后的回顾.原来一直使用的是阿里云的RDS数据库mysql版,主要是因为上次阿里云做活动可 ...
- NLP使用pytorch框架,pytorch安装
pytorch的安装方法及出现问题的解决方案: 安装pytorch,使用pip 安装,在运行代码的时候会报错,但是导包的时候不会报错,因此要采用conda的方式安装 1.找到miniconda的网 ...
- 搭建jumpser堡垒机
安装环境centos7 生产环境建议使用 1.4.8 版本 1.开始安装 echo -e "\033[31m 1. 防火墙 Selinux 设置 \033[0m" \ && ...