https://cn.vjudge.net/problem/UVA-10439

西安邀请赛被打自闭了,几何选手没有写出几何,疯狂刷几何ing

记得要用atan2函数来搞出倾斜角,然后记得加上2*PI

#include <bits/stdc++.h>
#define db double
using namespace std;
const db PI = acos(-1.0);
const db eps = 1e-4;
struct point
{
	db x;
	db y;
	point operator -(const point& other)
	{
		return point{ x - other.x, y - other.y };
	}
}que[5];
struct circle
{
	point o;
	db r;
};
int sign(db a)
{
	if (fabs(a) < eps)
		return 0;
	return a > 0 ? 1 : -1;
}
db dot(point q, point w)
{
	return q.x* w.x + q.y * w.y;
}
db cross(point q, point w)
{
	return q.x* w.y - w.x * q.y;
}
db getlen(point a)
{
	return sqrt(a.x * a.x + a.y * a.y);
}
db getangle(point q, point w)
{
	return acos(dot(q, w) / getlen(q) / getlen(w));
}
//已知三点坐标,求外接圆
circle waijiecircle(point p1, point p2, point p3)
{
	point b = point{ p2.x - p1.x,p2.y - p1.y };
	point c = point{ p3.x - p1.x,p3.y - p1.y };
	double temp = 2 * cross(b, c);
	double ox = (c.y * (b.x * b.x + b.y * b.y) - b.y * (c.x * c.x + c.y * c.y)) / temp + p1.x;
	double oy = (b.x * (c.x * c.x + c.y * c.y) - c.x * (b.x * b.x + b.y * b.y)) / temp + p1.y;
	point o = point{ ox,oy };
	return circle{ o,getlen(p1 - o) };
}
db angle[5];
int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		for (int i = 0; i < 3; i++)
			scanf("%lf%lf", &que[i].x, &que[i].y);
		circle o = waijiecircle(que[0], que[1], que[2]);
		for (int i = 0; i < 3; i++)
			angle[i] = atan2(que[i].y - o.o.y, que[i].x - o.o.x);
		sort(angle, angle + 3);
		angle[3] = angle[0];
		angle[0] = angle[1] - angle[0];
		angle[1] = angle[2] - angle[1];
		angle[2] = angle[3] - angle[2] + 2 * PI;
		for (int i = 3; i <= 200; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				db one = 2 * PI / i;
				db temp = fmod(angle[j] ,one);
				if (sign(temp) != 0 && sign(temp - one) != 0)
					goto qwe;
			}
			printf("%d\n", i);
			goto qqq;
			qwe:;
		}
		qqq:;
	}
}