#P12856. [NERC 2020 Online] Geometrical Combinatorics
[NERC 2020 Online] Geometrical Combinatorics
题目描述
Grace is developing a brand new theory of geometrical combinatorics --- a study about geometrical properties of combinatoric objects.
Consider two triangles on plane --- a Pascal's triangle and an ordinary triangle. Pascal's triangle is drawn with it's root at point (0, 0), and two sides along diagonals of upper-halfplane quarters. Formally, there are 1's written in points and , and between them at point there is a number equal to the sum of numbers at and at for all from to . An ordinary triangle is drawn as just a triangle with vertices at , , .
Grace defines an of Pascal's triangle and an ordinary triangle as the sum of values of Pascal's triangle inside or on the border of the ordinary triangle. Can you develop a program that calculates this intersection value?
输入格式
On the first line there is an integer () --- the number of tests to process. Each of the next lines contains 6 integers , , , , , (). Three points in each test do not lie on a line.
输出格式
For each test output an integer --- the intersection value modulo .
2
0 -1 -4 3 4 3
5 4 0 1 3 -2
15
2