#include
int main(){
int m, n, i, j;
double t1, t2, sum; //定义成实数
while(scanf("%d%d",&m,&n)!=EOF){
if(m==-1&&n==-1)break;
float a[1001][2]; //定义成浮点数,方便计算
for(i=0; i
scanf("%f",&a[i][j]); //注意输入格式
}
}
for(j=0; j
//按照J[i]/F[i],从大到小,对两个数组的数进行从大到小排序
t1 = a[i][0];
a[i][0] = a[i+1][0];
a[i+1][0] = t1;
t2 = a[i][1];
a[i][1] = a[i+1][1];
a[i+1][1] = t2;
}
}
sum=0.0;
for(i=0; i
//如果总food<=a[i][1],那么按照比例将m总值全部换成JavaBeans
sum+=a[i][0]*(m/a[i][1]);
m=0;
break;
}
else{
sum+=a[i][0];
m=m-a[i][1];
}
}
printf("%.3lf/n",sum);
}
return 0;
}