http://poj.org/problem?id=1252
来源:互联网 发布:linux移动文件到桌面 编辑:程序博客网 时间:2024/06/07 04:37
题意:由给定的6个数组成【1,100】中的每个数,(第一个数字是1)找出每个数的最少组合,让你求平均组合数和最大组合数
可以有负值:完全背包
//C++#include<iostream>#include<algorithm>#include<cstdio>#define max 10010using namespace std;int dp[max];int num[13];int T;int min(int a,int b){ return a>b?b:a;}int main(){ int Max,ans,M; scanf("%d",&T); while(T--) { ans=0; for(int i=0; i<=10; i+=2) { scanf("%d",&num[i]); num[i+1]=-num[i]; } M=num[10]*101;//由于有负值 for(int i=0; i<max; i++) dp[i]=max*max; dp[0]=0; for(int i=0; i<12; i+=2) for(int j=num[i]; j<=M; j++) { dp[j]=min(dp[j],dp[j-num[i]]+1); } for(int i=1; i<12; i+=2) for(int j=M+num[i]; j>=0; j--) { dp[j]=min(dp[j],dp[j-num[i]]+1); } Max=-1; for(int i=1; i<=100; i++) { if(Max<dp[i]) Max=dp[i]; ans+=dp[i]; } printf("%.2lf %d\n",ans/100.0,Max); } return 0;}
- http://poj.org/problem?id=1252
- http://poj.org/problem?id=2965
- http://poj.org/problem?id=2075
- http://poj.org/problem?id=1125
- http://poj.org/problem?id=2983
- http://poj.org/problem?id=2406
- http://poj.org/problem?id=1961
- http://poj.org/problem?id=1486
- http://poj.org/problem?id=1062
- http://poj.org/problem?id=2983
- http://poj.org/problem?id=3159
- http://poj.org/problem?id=1201
- http://poj.org/problem?id=3259
- http://poj.org/problem?id=3233
- http://poj.org/problem?id=1273
- http://poj.org/problem?id=3281
- http://poj.org/problem?id=1007
- http://poj.org/problem?id=1840
- 获取JPasswordField中文本内容
- Hive 入门详解
- skinmagic2.3破解版(MFC)皮肤美化
- 重建序列
- java笔记 StringBuffer容器笔记
- http://poj.org/problem?id=1252
- 关于VB6.0中控件加载的难题
- 【索引】访问方式
- 【程序41】学习static定义静态变量的用法
- 捕鱼达人:腾讯!让我说你什么好?
- 创建数据库用户,赋予访问某些表的权限
- SQL语言基础
- Invalid project specified问题(已解决)
- linux pm runtime