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. 利用ImageOps调整图片的Aspect Ratio(给图片添加borders)

    # -*- coding: utf-8 -*- #******************** # 改变图片的纵横比(aspect retio) # 使用ImageOps.expand() # Image ...

  2. Python中hashlib模块

    介绍hashlib hashlib 是一个提供了一些流行的hash算法的 Python 标准库.其中所包括的算法有 md5, sha1, sha224, sha256, sha384, sha512. ...

  3. python中的常用模块(2)

    在自动化测试中,经常需要查找操作文件,比如说查找配置文件(从而读取配置文件的信息),查找测试报告(从而发送测试报告邮件), 经常要对大量文件和大量路径进行操作,这就依赖于os模块. 1.当前路径及路径 ...

  4. 转:IOS里的动画

    摘要 本文主要介绍核iOS中的动画:核心动画Core Animation, UIView动画, Block动画, UIImageView的帧动画. 核心动画Core Animation UIView动 ...

  5. Linux清屏命令

    1:clear 2:Ctrl+L 3:printf "\033c" 4:ALT+F8 By KillerLegend Ref:http://www.coolcoder.in/201 ...

  6. 使用 Collections 实现排序 sort方法 对List 实体类实现Comparable类 示例

    package com.test.jj; import java.util.ArrayList; import java.util.Collections; public class Test { A ...

  7. javascript精雕细琢(二):++、--那点事

    目录 引言 ++和--在数学运算中的计算规则 ++和--在变量引用时的计算规则 ++和--的数据转换应用 引言 对于接触JS时间不长的前端来说,刚开始要实现诸如轮播图,选项卡等小模块时,肯定会用到in ...

  8. angularJS $resource

    $resource是一个更方便地与RESTful服务器API进行交互,可以方便地定义一个REST资源,而不必手动所有的声明CRUD方法的Service. 使用 1.要使用$resource首先要在HT ...

  9. 算法: 排序: 归并排序(Merge)

    http://www.codeproject.com/Articles/805587/Merge-Sort

  10. js封装Cookie操作

    var CookieUtil = { // 设置cookie set : function (name, value, expires, domain, path, secure) { var coo ...