Covered Points CodeForces - 1036E

http://codeforces.com/contest/1036/problem/E

卡B题时间太长 E没来及写。。

因为都是整数点 所以线段上的整数点数量就是横坐标之差与纵坐标之差的gcd+1

然后就是去重 n^2的求出所有交点 map去重

#include 
using namespace std;
#define ll long long
#define pll pair 
#define ppi pair 
const double eps=1e-6;

struct node1
{
    double x,y;
};

struct node2
{
    node1 s,e;
};

map  mp;
node2 seg[1010];
int n;

ll getabs(ll x)
{
    if(x>0) return x;
    else return -x;
}

ll getgcd(ll a,ll b)
{
    ll t;
    while(b>0)
    {
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

double cal(node1 a,node1 b,node1 c)//AB X AC
{
    return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
}

double getk(node1 p1,node1 p2)
{
    return (double)(p2.y-p1.y)/(double)(p2.x-p1.x);
}

bool judge(node1 a,node1 b,node1 c,node1 d)
{
    if(cal(a,b,c)*cal(a,b,d)

 

你可能感兴趣的:(计算几何)