标签:problem 整数 英文 lin tar content esc 图书 form
Description
Input
Output
Sample Input
Sample Output
#include <iostream> #include <cstring> #include <cstdio> using namespace std; const int max_s = 3000001;//靠计算的。。 int f[max_s],c[40]; int main() { int i,j,n,A,B,C,num,q; double M,m; char op; while(scanf("%lf%d",&M,&n),n) { q=(int)(M*100);//转化为int型 int k=0; for(i=0; i<n; i++) { scanf("%d",&num); int flag=0; A=B=C=0; while(num--) { getchar(); scanf("%c:%lf",&op,&m); if(op!=‘A‘&&op!=‘B‘&&op!=‘C‘) flag=1; if(!flag) { if(op==‘A‘) A+=(int)(m*100); else if(op==‘B‘) B+=(int)(m*100); else if(op==‘C‘) C+=(int)(m*100); if(A>60000||B>60000||C>60000||(A+B+C)>100000) { flag=1; continue; } } } if(!flag) c[k++]=A+B+C; } memset(f,0,sizeof(f)); for(i=0; i<k; i++) { for(j=q; j>=c[i]; j--) { if(f[j-c[i]]+c[i]>f[j]) f[j]=f[j-c[i]]+c[i];//dp } } double L=(double)f[q]/100.0; printf("%.2lf\n",L); } return 0; }
标签:problem 整数 英文 lin tar content esc 图书 form
原文地址:http://www.cnblogs.com/l609929321/p/6718602.html