hdu1070

#include <stdio.h>
#include <string.h>
struct milk{
char brand[128];
int price;
int volume;
double value;
}a[100];
int main(void){
int i,t,n,d;
struct milk tmp;
scanf("%d",&t);
while (t--){
scanf("%d",&n);
for (i=0; i<n; i++){
scanf("%s %d %d",a[i].brand,&a[i].price,&a[i].volume);
d = a[i].volume/200;
if (d==0)
a[i].value = 3.4e+38; // 小于200毫升则费用最高
else if (d<=5)
a[i].value = (double)a[i].price/d;
else
a[i].value = (double)a[i].price/5;
}
tmp = a[0];
for (i=1; i<n; i++)
if (a[i].value<tmp.value)
tmp = a[i];
else if (a[i].value==tmp.value && a[i].volume>tmp.volume)
tmp = a[i];
printf("%s ",tmp.brand);
}
return 0;
}

原文地址:https://www.cnblogs.com/wangkun1993/p/6337656.html