1 人解决，12 人已尝试。
2 份提交通过，共有 34 份提交。
9.9 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
Some pranksters have watched too much Discovery Channel and now they want to build a crop triangle during the night. They want to build it inside a large crop that looks like an evenly spaced grid from above. There are some trees planted on the field. Each tree is situated on an intersection of two grid lines (a grid point). The pranksters want the vertices of their crop triangle to be located at these trees. Also, for their crop triangle to be more interesting they want the center of that triangle to be located at some grid point as well. We remind you that if a triangle has the vertices , and , then the center for this triangle will have the coordinates .
You will be given a set of points with integer coordinates giving the location of all the trees on the grid. You are asked to compute how many triangles you can form with distinct vertices in this set of points so that their center is a grid point as well (i.e. the center has integer coordinates).
If a triangle has area we will still consider it a valid triangle.
The first line of input gives the number of cases, . test cases follow. Each test case consists of one line containing the integers and separated by exactly one space. will be the number of trees in the input set. Using the numbers and the following pseudocode will print the coordinates of the trees in the input set.
mod indicates the remainder operation.
The parameters will be chosen such that the input set of trees will not have duplicates.
X = x0, Y = y0 print X, Y for i = 1 to n-1 X = (A * X + B) mod M Y = (C * Y + D) mod M print X, Y
For each test case, output one line containing
Case #X: where is the test case number (starting from 1). This should be followed by an integer indicating the number of triangles which can be located at distinct trees and has a center that is a grid point.
2 4 10 7 1 2 0 1 20 6 2 0 2 1 1 2 11
Case #1: 1 Case #2: 2
In the first test case, the 4 trees in the generated input set are (0, 1), (7, 3), (17, 5), (17, 7).