CF1548D2.Gregor and the Odd Cows (Hard)
NOI/NOI+/CTSC
通过率:0%
时间限制:6.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is the hard version of the problem. The only difference from the easy version is that in this version the coordinates can be both odd and even.
There are n fence-posts at distinct coordinates on a plane. It is guaranteed that no three fence posts lie on the same line.
There are an infinite number of cows on the plane, one at every point with integer coordinates.
Gregor is a member of the Illuminati, and wants to build a triangular fence, connecting 3 distinct existing fence posts. A cow strictly inside the fence is said to be enclosed. If there are an odd number of enclosed cows and the area of the fence is an integer, the fence is said to be interesting.
Find the number of interesting fences.
这是该问题的困难版本。与简单版本的唯一区别在于:在此版本中,坐标可以为奇数或偶数。
平面上有 n 根互不重合的栅栏柱,其坐标互不相同。保证任意三根栅栏柱都不共线。
平面上有无限多头牛,每头牛位于一个整数坐标点上(即所有 (x,y) 满足 x,y∈Z 的点上各有一头牛)。
Gregor 是光明会成员,他想用三根已有的、互不相同的栅栏柱构建一个三角形围栏。严格位于该围栏内部的牛称为被围住的牛。若被围住的牛的数量为奇数,且该围栏的面积为整数,则称该围栏是有趣的。
请计算有趣的围栏的数量。
输入格式
The first line contains the integer n (3≤n≤6000), the number of fence posts which Gregor can choose to form the vertices of a fence.
Each of the next n line contains two integers x and y (0≤x,y≤107, where (x,y) is the coordinate of a fence post. All fence posts lie at distinct coordinates. No three fence posts are on the same line.
第一行包含一个整数 n(3≤n≤6000),表示 Gregor 可用于构成围栏顶点的围栏桩数量。
接下来的 n 行中,每行包含两个整数 x 和 y(0≤x,y≤107),其中 (x,y) 是一个围栏桩的坐标。所有围栏桩的坐标互不相同,且任意三个围栏桩不共线。
输出格式
Print a single integer, the number of interesting fences. Two fences are considered different if they are constructed with a different set of three fence posts.
输出一个整数,表示有趣的围栏的数量。如果两个围栏所使用的三根围栏柱子集合不同,则认为它们是不同的围栏。
输入输出样例
输入#1
3 0 0 2 0 0 4
输出#1
1
输入#2
4 1 8 0 6 5 2 5 6
输出#2
1
输入#3
10 170 59 129 54 5 98 129 37 58 193 154 58 24 3 13 138 136 144 174 150
输出#3
29
说明/提示
In the first example, there is only 1 fence. That fence is interesting since its area is 4 and there is 1 enclosed cow, marked in red.

In the second example, there are 4 possible fences. Only one of them is interesting however. That fence has an area of 8 and 5 enclosed cows.

在第一个例子中,只有一道围栏。这道围栏是“有趣的”,因为其面积为 4,且围住了 1 头牛(以红色标出)。

在第二个例子中,共有 4 种可能的围栏。但其中仅有一种是“有趣的”。该围栏的面积为 8,围住了 5 头牛。

输入解题思路,AI测评打分。不知道怎么写?