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个数 ...
随机推荐
- 【leecode】 Course Schedule
class Solution { public: static bool canFinish(int numCourses, vector<pair<int, int>>&am ...
- docker xfs卡死
原因 docker在xfs文件系统中,过于频繁create/destory container.pull/push image,当thin pool满时,DeviceMapper后端默认文件系统xfs ...
- error: snap "eclipse" has "install-snap" change in progress
在Ubuntu 18.04使用snap安装eclipse软件报时错: inuxidc@linuxidc:~$ snap install --classic eclipse error: snap &q ...
- 在论坛中出现的比较难的sql问题:25(字符串拆分3)
原文:在论坛中出现的比较难的sql问题:25(字符串拆分3) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方法了. 所以,觉得有必要记录下 ...
- Windows下的Android Studio环境搭建、安装使用
https://jingyan.baidu.com/article/20b68a88ff2ca4796cec6232.html https://blog.csdn.net/jklinux/articl ...
- 简介:google ctemplate:简单易用的文字模板(转载)
转自:http://blog.csdn.net/aladdina/article/details/4531736 CTemplate 是一个简单实用.功能强大的文字模板(template langua ...
- vue创建组件的几种方法
<html> <head> <title>vue创建组件</title> <meta charset="utf-8"> ...
- 移动端调试工具Vconsole
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- html+css+javascript网页制作技巧总结1
(一)div.元素居中中显示方法: 1.宽度要有实际值或百分比值 2.margin:0px auto; 文本内容居中显示的方法: 1.text-align:center; 2.line-height: ...
- springboot 常见的启动器
<!--pringBoot提供了一个名为spring-boot-starter-parent的工程, 里面已经对各种常用依赖(并非全部)的版本进行了管理 我们的项目需要以这个项目为父工程,这样我 ...