Codeforces 837D
来源:互联网 发布:阿里云邮件服务器设置 编辑:程序博客网 时间:2024/06/06 04:19
题意:给出n个数,让你从中选出k个数,使得它们乘积的后缀0最多,输出这个值。
Input
3 2
50 4 20
Output
3
Input
5 3
15 16 3 25 9
Output
3
Input
3 3
9 77 13
Output
0
Note
In the first example there are3 subsets of 2 numbers. [50, 4] has product 200 with roundness2,[4, 20] — product 80,roundness1,[50, 20] — product 1000,roundness3.
In the second example subset[15, 16, 25] has product 6000,roundness3.
In the third example all subsets has product withroundness0.
这题做过,但是在一些细节的地方自己又不会处理。。
while(~scanf("%d%d",&n,&k)) { for(int i=0;i<=k;i++) for(int j=0;j<maxm;j++) { dp[i][j]=-INF; } dp[0][0]=0; for(int i=0;i<n;i++) { int n2=0,n5=0; scanf("%I64d",&x); while(x%2==0) x/=2,n2++; while(x%5==0) x/=5,n5++; for(int j=k;j>=1;j--) for(int l=n2;l<maxm;l++) //这个地方是这样的。多做题应该就会了。 { dp[j][l]=max(dp[j][l],dp[j-1][l-n2]+n5); } } int ans=0; for(int i=1;i<maxm;i++) { ans=max(ans,min(i,dp[k][i])); } printf("%d\n",ans); }
阅读全文
0 0
- Codeforces 837D
- Codeforces 837D
- Codeforces 837 D Round Subset
- Codeforces-837D Round Subset(dp)
- 【dp】codeforces 837D Round Subset
- codeforces 837D Round Subset (dp)
- Codeforces-837D:Round Subset(DP)
- CodeForces 617D CodeForces 617D
- CodeForces 101D
- CodeForces 103D
- CodeForces 222D Olympiad
- codeforces 242d
- CodeForces 111D
- 【codeforces】3D
- CodeForces 127D Password
- codeforces 257D. Sum
- Codeforces 292D
- Codeforces 275D
- Apache与CDH的比较
- LintCode67
- PCB绘图,覆铜区域或信号线附近添加几排过孔的作用
- LG G2修复弹出n个未识别磁盘
- 大数据生态系统基础:Hadoop(四):Hadoop 3.0.0 HDFS SHELL 命令
- Codeforces 837D
- java单例模式之懒汉模式和饿汉模式
- STL之String
- 单张图片上传与回显
- Java泛型学习-20170819
- iOS
- bindService 分析---之二
- web前端学习日记25-------在线简历的完成
- 2017.8.19. 高精度