<题目链接> <转载于 >>>  > 题目大意: 在二维平面上给出n条不共线的线段(线段端点是整数),问这些线段总共覆盖到了多少个整数点. 解题分析: 用GCD可求的某条给定线段上有多少个整数点,理由如下: GCD(n,m)为n与m的最大公约数,通过辗转相除法求得.令g=GCD(n,m); n=x*g, m=y*g.所以将横坐标分为g个x份,将纵坐标分为g个y份.所以,本题线段覆盖的整数点个数为 g+1 (因为包含端点,如果不包含端点就为 g-1 ). 但是这样求…
题目链接:https://codeforces.com/contest/1036/problem/E 思路:学会了一个在线段上的整数点等于 GCD(x1 - x2, y1 - y2) +  1,然后去重线段相交的重复整点. AC代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; int sgn(double x) { ; ? - : ; } struct Point{ double x, y; P…
E. Covered Points 利用克莱姆法则计算线段交点.n^2枚举,最后把个数开方,从ans中减去. ans加上每个线段的定点数, 定点数用gcs(△x , △y)+1计算. #include <algorithm> #include <iterator> #include <iostream> #include <cstring> #include <cstdlib> #include <iomanip> #include…
题目大意: 默认从零点开始 给定n次x y上的移动距离 组成一个n边形(可能为凹多边形) 输出其 内部整点数 边上整点数 面积 皮克定理 多边形面积s = 其内部整点in + 其边上整点li / 2 - 1 那么求内部整点就是 in = s + 1 - li / 2 求整个多边形边上的整点数 //求两点ab之间的整点数 int lineSeg(P a,P b) { int dx=abs(a.x-b.x), dy=abs(a.y-b.y); && dy==) ; ; // 不包括a b两个顶…
1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3621  Solved: 1605[Submit][Status][Discuss] Description 求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数. Input 只有一个正整数n,n<=2000 000 000 Output 整点个数 Sample Input 4 Sample Output 4 HINT   Sourc…
1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4210  Solved: 1908[Submit][Status][Discuss] Description 求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数. Input 只有一个正整数n,n<=2000 000 000 Output 整点个数 Sample Input 4 Sample Output 4 HINT 科普视频 So…
\(\\\) Description 给出一个整数 \(r\) ,求圆 \(x^2+y^2=r^2\) 上的整点数. \(r\le 2\times 10^9\) \(\\\) Solution 神题. 可以注意到,坐标轴上共有四个整点,其余位置各个象限里整点数相同,所以我们只需要计算第一象限的答案. 首先有方程 \[ x^2+y^2=r^2 \] 移项,得 \[ x^2=r^2-y^2=(r+y)(r-y) \] 设 \(d=gcd(r+y,r-y)\),有 \[ x^2=\frac{r+y}{…
 Covered Points Count time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given nn segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments…
C - Covered Points Count CodeForces - 1000C You are given nn segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each othe…
题面 给定圆的半径,求圆上整点数 这是一道很Nice的数学题!超爱!好吧,由于这道题,我去Study了一下复数(complex number)复杂的数 真棒!!! 有兴趣的戳这里!!!\(\huge \to\) 思路: 高斯素数的原理,将整数分解质因数后,再把每个质因数分解成高斯素数,对于质数4n+1,它可以有效的分解成高斯素数,而质数4n+3不能,因为3无法分解为高斯素数,所以当一个数有奇数个3因子时,这个圆上没有整点,而3的个数为偶数时,由于能分成两组配对,所以有整点,但3对Ans的影响为0…