当前位置:网站首页>CF736 D2
CF736 D2
2022-06-22 11:41:00 【caoyang1123】
Compared with easy Removed the condition that the coordinates are even , So now S The area of should also be considered .
S = a + b/2 - 1
2S = 2a + b - 2
a Is odd ,S Is an integer
You can get what you need at this time 2S mod 4 = b mod 4
b According to the previous formula sigma gcd(abs(xi - xj), abs(yi - yj)) Ask for ,2S Then we can use the cross product to find
Consider and easy The same thing , Put all the coordinate modules 4 discretization , There's a problem , In seeking b When , When two numbers are subtracted 4 more than 1、 model 4 more than 3 Will transform each other ,b Among the feasible solutions are 1 + 3 + 2 And so on. , So the method is right b invalid , But for 2S Because as long as you ask for the surplus 2 or 4 Can still be established .
here , We enumerate more things to make sure it works , Open an array hav[i][nw][x][y], To express with i produce b by nw, Abscissa mod 4 = x And ordinate mod 4 = y Number of elements of , violence n^2logn seek
After that 1+3+2 And so on , Then enumeration 1 and 3 Adjacent edge of , be left over 2 The opposite side of is similar to easy The version can be judged .
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define sc second
#define pb push_back
#define ll long long
#define trav(v, x) for(auto v:x)
#define VI vector<int>
#define all(x) (x).begin(),(x).end()
using namespace std;
const double eps = 1e-10;
const int N = 6050;
const ll mod = 998244353;
pii pt[N];
int hav[N][4][4][4];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> pt[i].fi >> pt[i].sc;
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
if(i == j)
continue;
int nw = __gcd(abs(pt[i].fi - pt[j].fi), abs(pt[i].sc - pt[j].sc)) % 4;
hav[i][nw][pt[j].fi % 4][pt[j].sc % 4]++;
//cerr << "!!" << i << ' ' << nw << ' ' << pt[j].fi % 4 << ' ' << pt[j].sc % 4 << '\n';
}
}
ll ans = 0, res = 0;
//case 1
for(int i = 1; i <= n; i++)
{
int x1 = pt[i].fi % 4;
int y1 = pt[i].sc % 4;
for(int x2 = 0; x2 < 4; x2++)
{
for(int y2 = 0; y2 < 4; y2++)
{
for(int b1 = 1; b1 <= 3; b1 += 2)
{
ll num1 = hav[i][b1][x2][y2];
for(int x3 = 0; x3 < 4; x3++)
{
for(int y3 = 0; y3 < 4; y3++)
{
for(int b2 = 1; b2 <= 3; b2 += 2)
{
ll tmp;
int b = __gcd(abs(x2 - x3), abs(y2 - y3)) % 4;
b = (b + b1 + b2) % 4;
if(b != 0 && b != 2)
continue;
int SS = abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) % 4;
if(b != SS)
continue;
if(b1 == b2 && x3 == x2 && y3 == y2)
tmp = num1 * (num1 - 1);
else
tmp = num1 * hav[i][b2][x3][y3];
ans += tmp;
}
}
}
}
}
}
}
// case 2
for(int i = 1; i <= n; i++)
{
int x1 = pt[i].fi % 4;
int y1 = pt[i].sc % 4;
for(int x2 = 0; x2 < 4; x2++)
{
for(int y2 = 0; y2 < 4; y2++)
{
for(int b1 = 0; b1 <= 2; b1 += 2)
{
ll num1 = hav[i][b1][x2][y2];
for(int x3 = 0; x3 < 4; x3++)
{
for(int y3 = 0; y3 < 4; y3++)
{
for(int b2 = 0; b2 <= 2; b2 += 2)
{
ll tmp;
int b = __gcd(abs(x2 - x3), abs(y2 - y3)) % 4;
b = (b + b1 + b2) % 4;
if(b != 0 && b != 2)
continue;
int SS = abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) % 4;
if(b != SS)
continue;
if(b1 == b2 && x3 == x2 && y3 == y2)
tmp = num1 * (num1 - 1);
else
tmp = num1 * hav[i][b2][x3][y3];
res += tmp;
}
}
}
}
}
}
}
//cerr << res << '\n';
cout << (ans / 2) + (res / 6) << '\n';
}
边栏推荐
- 云端极简部署Svelte3聊天室
- 奋斗吧,程序员——第三十六章 落花人独立,微雨燕双飞
- 奋斗吧,程序员——第四十二章 会挽雕弓如满月,西北望,射天狼
- 奋斗吧,程序员——第三十九章 人生不失意,焉能慕知己
- R语言使用自定义函数编写深度学习阶跃step激活函数、并可视化阶跃step激活函数
- How many of the eight classic MySQL errors did you encounter?
- haas506 2.0开发教程-高级组件库-modem.info(仅支持2.2以上版本)
- Flink status management
- 【软工】 设计模块
- From prototype chain to inheritance, illustrate the context and recommend collection
猜你喜欢

puzzle(019)平面正推问题

庖丁解牛,这八个MySQL经典错误,你遇到几个?

Go microservice (I) - getting started with RPC

Security risks exist in open source code: an average of 49 vulnerabilities exist in a project

1.11 haas506 2.0开发教程-driver-RTC(仅支持2.2以上版本)

开源代码存在安全隐患:一个项目平均有49个漏洞

NFT交易平台数字藏品系统开发技术

Basic principles of the Internet

Rtklib postpos carding (taking single point positioning as an example)

Should the theme of the IDE be bright or dark? Here comes the ultimate answer!
随机推荐
【云图说】 第244期 三分钟了解容器镜像服务
TCP connection establishment process (in-depth understanding of the source code and three handshakes)
electron添加SQLite數據庫
【软工】 概论 & 过程和生命周期建模
CF751 C. Optimal Insertion
R语言epiDisplay包的idr.display函数获取泊松回归poisson模型的汇总统计信息(初始事件密度比IDR值、调整事件密度比IDR值及其置信区间、Wald检验的p值和似然比检验的p值)
Call center terminology
Attack and defense drill | threat hunting practice case based on att & CK
How to improve customer conversion rate on the official website
CISP textbook update: introduction to the new knowledge system of eight knowledge domains in 2019
【软工】 设计模块
social phobia? When I introduce myself, my brain goes blank?
7-1 framework Publishing - publishing framework through NPM
Flink状态管理
Rtklib postpos carding (taking single point positioning as an example)
electron添加SQLite数据库
JG_ fx_ twenty million two hundred and twenty thousand six hundred and twenty
牛客挑战赛55E题解
6-9 inter application communication - sub application communication
R language uses read Table load the data set (CSV data) of conditional logistic regression analysis, and use the unique function to view the number of groups of paired data