标签:类型 允许 最大数 输出 sim can main class line
200.00 3 2 A:23.50 B:100.00 1 C:650.00 3 A:59.99 A:120.00 X:10.00 1200.00 2 2 B:600.00 A:400.00 1 C:200.50 1200.50 3 2 B:600.00 A:400.00 1 C:200.50 1 A:100.00 100.00 0
123.50 1000.00 1200.50
#include <stdio.h> double bill[30]; double findMax(int end, double sum, double limit){ if(end==0) return sum; double max=findMax(end-1, sum, limit); if(sum+bill[end-1]<=limit){ double tmp=findMax(end-1, sum+bill[end-1], limit); max=max>tmp?max:tmp; } return max; } int main(){ double limit, singleValue, value, max; int n, m, index; char type; bool flag; while(scanf("%lf%d", &limit, &n)!=EOF&&n){ index=0; for(int i=0;i<n;++i){ scanf("%d", &m); value=0; flag=true; for(int j=0;j<m;++j){ scanf(" %c:%lf", &type, &singleValue); // 还能这么玩的!!! if(!flag||type<‘A‘||type>‘C‘||singleValue>600) flag=false; else{ value+=singleValue; if(!flag||value>1000) flag=false; } } if(flag) { bill[index++]=value; } } max=findMax(index, 0, limit); printf("%.2lf\n", max); } return 0; }
标签:类型 允许 最大数 输出 sim can main class line
原文地址:https://www.cnblogs.com/bernieloveslife/p/9736557.html