题目地址:pdf版本
直接建立坐标系,设A(0,0) B(0,1) 然后就是利用模板进行计算了。
代码:
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
const double eps=1e-10;
const double PI=acos(-1);
using namespace std;
struct Point{
double x;
double y;
Point(double x=0,double y=0):x(x),y(y){}
void operator<<(Point &A) {cout<<A.x<<' '<<A.y<<endl;}
};
int dcmp(double x) {return (x>eps)-(x<-eps); }
typedef Point Vector;
Vector operator +(Vector A,Vector B) { return Vector(A.x+B.x,A.y+B.y);}
Vector operator -(Vector A,Vector B) { return Vector(A.x-B.x,A.y-B.y); }
Vector operator *(Vector A,double p) { return Vector(A.x*p,A.y*p); }
Vector oper