首页 > 代码库 > hdu1070
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 = http://www.mamicode.com/3.4e+38; // 小于200毫升则费用最高
else if (d<=5)
a[i].value = http://www.mamicode.com/(double)a[i].price/d;
else
a[i].value = http://www.mamicode.com/(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=http://www.mamicode.com/=tmp.value && a[i].volume>tmp.volume)
tmp = a[i];
printf("%s\n",tmp.brand);
}
return 0;
}
hdu1070