10300-ecological premiumtime limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem &problem=1241
German farmers are given a premium depending on the conditions at their. Imagine the following simplified regulation:you know the size of each farmer ' s farmyard in square meters and the number O F Animals living at it. We won ' t make a difference between different animals, although the this are far from reality. Moreover you have information about the degree farmer uses environment-friendly equipment and practices, expressed in A single integer greater than zero. The amount of money a farmer receives can is calculated from these parameters as follows. The "need" a single animal occupies in an average. This value (in square meters) are then multiplied by the parameter that stands for the farmer ' s environment-friendliness, R Esulting in the premium a farmer are paid per animal he owns. To compute the final premium of a farmer just multiply this premium the animal of the animals.
Input
The a single positive integer n (<20), the number of test cases. Each test case starts with a line containing a single integer f (0<f<20), the number of farmers in the test Case. This are followed by one line per farmer containing three positive integers each:the size of the farmyard in square m Eters, the number of animals he owns and the integer value that expresses the farmer ' s environment-friendliness. The Input is terminated by the end of file. No integer in the "input is greater than 100000 or less than 0."
Output
For each test case output one line containing a single integer that holds the summed burden for Germany ' s budget, which WI ll always be a whole number. Don't output any blank lines.
Sample Input
3
5
1 1 1
2 2 2
3 3 3
2 3 4
8 9 2
3
9 1 8
6 12 1
8 1 1
3
10 30 40
9 8 5
100 1000 70
Sample Output
38
86
7445
Learn English:
The "need" a single animal occupies in an average. This value (in square meters) are then multiplied by the parameter that stands for the farmer ' s environment-friendliness, R Esulting in the premium a farmer are paid per animal he owns. To compute the final premium of a farmer just multiply this premium the animal of the animals.
First you need to (figure out) the average area of each animal, using this number (unit: m^2) to multiply the farmer's environmental friendliness, which is the result of the farmer's insurance premiums for each animal he has to pay (P). To calculate the final premium of a farmer, just multiply p by the number of animals he has.
Said so much, that is, the area of X environmental friendliness.
Complete code:
/*0.009s*/
#include <cstdio>
int main (void)
{
int case, Test, sum, x, Y, Z;
scanf ("%d", &case);
while (case--)
{
sum = 0;
scanf ("%d", &test);
while (test--)
{
scanf ("%d%d%d", &x, &y, &z);
sum + = x * z;
}
printf ("%d\n", sum);
}
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/