10300 Ecological Premium

Problem link: 10300 – Ecological Premium

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1241

#include<stdio.h>
double burden(int _land,int _animals,int _environment);
int main()
{
int _test;
while(scanf("%d",&_test)!=EOF){
int _case;
for(_case=1;_case<=_test;_case++){
int _test2,_case2;
scanf("%d",&_test2);
double _cost;
double _total_cost=0;
for(_case2=1;_case2<=_test2;_case2++){
int _land,_animals,_environment;
scanf("%d %d %d",&_land,&_animals,&_environment);
_cost=burden(_land,_animals,_environment);
_total_cost=_total_cost+_cost;
}
int _total_cost2=_total_cost;
printf("%dn",_total_cost2);
}
}
return 0;
}
double burden(int _land,int _animals,int _environment)
{
double l=_land,a=_animals,e=_environment;
double _individual_cost;
_individual_cost=(((l/a)*e)*a);

return (_individual_cost);
}

Advertisements