D - Round Subset

思路:背包;

代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
ll n,m,dp[][],tmp,p2,p5,pos,sum,ans;
int main()
{
//freopen("data.txt","r",stdin);
scanf("%lld%lld",&n,&m);
memset(dp,-0x7f,sizeof(dp)),dp[][]=;;
for(ll i=;i<=n;i++)
{
cin>>tmp,pos=tmp,p5=,p2=;
while(pos%==) pos/=,p2++;
while(tmp%==) tmp/=,p5++;
sum+=p5;
for(ll v=min(i,m);v>=;v--)
for(ll e=sum;e>=p5;e--) dp[v][e]=max(dp[v][e],dp[v-][e-p5]+p2);
}
for(ll i=;i<=sum;i++) ans=max(ans,min(i,dp[m][i]));
cout<<ans;
return ;
}

D - Round Subset codeforces837d的更多相关文章

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

  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(背包)

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

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

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

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

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

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

  8. 【Codeforces 837D】Round Subset

    http://codeforces.com/contest/837/problem/D 分解质因数,即第i个数的因子2的个数为c2[i],因子5的个数为c5[i],末尾零的个数就是min{Σc2[i] ...

  9. Educational Codeforces Round 26-D. Round Subset

    题目大意:给你n个数字(小于1e18),从n个数中取k个数字相乘,使其后缀0最多,问你后缀0最多是多少. 知道得用三维的dp[ i ] [ j ] [ k ]  第一维表示用到第 i 个数为止,j 表 ...

随机推荐

  1. GO_05_2:Golang 中 panic、recover、defer 的用法

     函数 defer 1. 它的执行方式类似其他语言中的折构函数,在函数体执行结束后按照调用顺序的 相反顺序 逐个执行 2. 即使函数发生 严重错误 也会被执行,类似于 java 中 try{...} ...

  2. NAT—网络地址转换

    参考链接:http://www.qingsword.com/qing/745.html 视频链接: 一.什么是NAT? NAT --- Network Address Translation  也就是 ...

  3. .NET 定时器类及使用方法

    Timer类实现定时任务 //2秒后开启该线程,然后每隔4s调用一次 System.Threading.Timer timer = new System.Threading.Timer((n) =&g ...

  4. H.265 Video Encoder IP Core

    复制: 开源H.265硬件视频编码器H.265 Video Encoder IP Core是开源的H.265硬件视频编码器,实现了H.265(或叫HEVC)的大部分功能. 它由复旦大学专用集成电路与系 ...

  5. [csp-201809-4]再卖菜 差分约束or记忆化搜索

    先更新第一个做法:差分约束 转化成最长路,求出的每一个解是满足差分方程的最小值 spfa求最短路 对于边(x->y) 有: if(dis[y] > dis[x] + a[i].d) dis ...

  6. 【Loadrunner】LR参数化:利用mysql数据库里面的数据进行参数化

    很多同学都在自学loadrunner去做压力测试,但是如果要利用LR做压力测试,或者是其他工具,其中有一个环节是我们避开不了的,比如说:参数化 今天华华就给大家简要的介绍下,如果你要做的参数化的数据来 ...

  7. UNIX网络编程 第3章 套接字编程简介

    套接字结构类型和相关的格式转换函数

  8. 将网址url中的参数转化为JSON格式

    网上方法很多,各种奇技淫巧,这里贴上一种较为正常的思路. 主要利用split对获取的字符串不断进行分割,最后获得所需要的格式. 代码如下 <!DOCTYPE html> <html ...

  9. 读书笔记 effective c++ Item 48 了解模板元编程

    1. TMP是什么? 模板元编程(template metaprogramming TMP)是实现基于模板的C++程序的过程,它能够在编译期执行.你可以想一想:一个模板元程序是用C++实现的并且可以在 ...

  10. MySQL -- JDBC

    一 . JDBC的开发步骤 1.准备四大参数 2.注册驱动 3.获得连接 4.获得语句执行者 5.执行sql语句 6.处理结果 7.释放资源 1.准备四大参数 /* * jdbc四大配置参数 * &g ...