Šljivik - Okružno
Srba has a plum garden in the heart of Shumadija. Since Srba is a perfectionist, he maintains his plum garden in the shape of a rectangle, so that each of a total of N rows contains exactly M plum trees. Srba keeps control of the number of plum fruits on each tree.
Srba is a proud father of K kids, who love plums, and to make them happy, he decided to skim the same number of plum fruits for his every child. But, since he is a perfectionist, Srba will choose the part of his plum garden in the shape of a rectangle, with sides parallel to the sides of the garden, so that when he finishes skimming all the fruits, all his children get the same number of plum fruits.
Count the number of ways Srba can choose the desired part of his plum garden.
3 3 5
2 9 3
10 8 6
1 4 12Sample output:
4Explanation.
The following rectangles are solutions (the first two numbers are the coordinates of the upper left corner, and the other two are the coordinates of the lower right corner of the rectangle): (1,1)-(3,3) , (2,1)-(2,1) , (3,1)-(3,2) , (2,2)-(3,3).
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.