Friday, January 16, 2009

UVa problem 10300: sample algorithm

For problem 10300, Ecological Premium, for each farmer case, one is given three parameters: land area (land_area), number of animals (num_animals), and degree of environmental friendliness (degree_friendliness). The problem describes that the premium due to the farmer is calculated as Equation 1.

[Equation 1]
premium = (land_area / num_animals) * degree_friendliness * num_animals

But notice from Equation 1 that num_animals can be cancelled out to simplify the formula to Equation 2.

[Equation 2]
premium = land_area * degree_friendliness

In this case, the num_animals parameter is not needed and is used to confused the solver.

So, for a given test case, we calculate the premium for each farmer. Then we sum them up to obtain the burden due by the government.

No comments:

Post a Comment