比赛 20161114 评测结果 C
题目名称 输出全靠花 最终得分 0
用户昵称 sxysxy 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2016-11-14 11:19:15
显示代码纯文本
#include <cstdlib>
#include <cstdarg>
#include <cstring>
#include <iostream>
#include <list>
#include <queue>
#include <vector>
using namespace std;
int gcd(int a, int b)
{
	return b?gcd(b, a%b):a;
}
class ratio
{
	int a, b;
	int sign;
	inline void check_sign()
	{
		if(a >= 0 && b >= 0)
			sign = 0;
		else if(a < 0 && b < 0)
			sign = 0;
		else
			sign = 1;
	}
public:
	inline void simpify()
	{
		int k = gcd(a, b);
		a /= k;
		b /= k;
		check_sign();
	}
	ratio(int u = 1, int d = 1)
	{
		a = u, b = d;
		simpify();
		check_sign();
	}
	ratio operator+(ratio x)
	{
		int k = b*x.b/gcd(b, x.b);
		return ratio(a*(k/b)+x.a*(k/x.b), k);
	}
	ratio operator*(ratio x)
	{
		return ratio(a*x.a, b*x.b);
	}
	bool operator==(ratio x)
	{
		simpify();
		x.simpify();
		return (sign == x.sign && a == x.a && b == x.b);
	}
};
bool operator!=(ratio x, ratio y)
{
	return !(y == x);
}

struct point
{
	int pts[5];
}ps[1002];
struct line
{
	point pres;
	ratio d[5][5];
	bool online(point &x)
	{
		for(int i = 1; i <= 3; i++)
			for(int j = i+1; j <= 4; j++)
			{
				ratio t(pres.pts[i]-x.pts[i], pres.pts[j]-x.pts[j]);
				if(t != d[i][j])return false;
			}
		return true;
	}
	void make(point &a, point &b)
	{
		for(int i = 1; i <= 3; i++)
			for(int j = i+1; j <= 4; j++)
				d[i][j] = ratio(a.pts[i]-b.pts[i], a.pts[j]-b.pts[j]);
	}
};
int main()
{
	freopen("xumingshi.in", "r", stdin);
	freopen("xumingshi.out", "w", stdout);
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= 4; j++)
			scanf("%d", &ps[i].pts[j]);
	int maxc = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i+1; j <= n; j++)
		{
			int c = 2;
			line li;
			li.make(ps[i], ps[j]);
			li.pres = ps[i];
			for(int k = 1; k <= n; k++)
			{		
				if(k != i && k != j)
				{	
					if(li.online(ps[k]))
						c++;
				}
			}
			maxc = max(maxc, c);
		}
	}
	printf("%d\n", maxc);
	return 0;
}