记录编号 349079 评测结果 AAAAAAATTT
题目名称 输出全靠花 最终得分 70
用户昵称 GravatarTabing010102 是否通过 未通过
代码语言 C++ 运行时间 3.072 s
提交时间 2016-11-14 19:25:03 内存使用 0.27 MiB
显示代码纯文本
#include <cstdio>
#include <cstdlib>
using namespace std;
const double eps = 1e-4;
const int maxn = 1000+10;
FILE *fin, *fout;
struct Node {
	int x, y, z, w;
	Node(int a, int b, int c, int d) { x=a; y=b; z=c; w=d; }
	Node(){;}
}nodes[maxn];
int n, ans=2;
double abs(double a) { return a<0?-a:a; }
bool isal(int a, int b, int c) {
	if(abs(nodes[b].x-nodes[a].x) <= eps) {
		return (abs(nodes[b].y-nodes[a].y)<=eps &&
				abs(nodes[b].z-nodes[a].z)<=eps &&
				abs(nodes[b].w-nodes[a].w)<=eps);
	} else {
		double k1 = (double)(nodes[c].x-nodes[a].x)/(nodes[b].x-nodes[a].x);
		double k2 = (double)(nodes[c].y-nodes[a].y)/(nodes[b].y-nodes[a].y);
		double k3 = (double)(nodes[c].z-nodes[a].z)/(nodes[b].z-nodes[a].z);
		double k4 = (double)(nodes[c].w-nodes[a].w)/(nodes[b].w-nodes[a].w);
		return ((abs(k1-k2)<=eps) && (abs(k2-k3)<=eps)
		     && (abs(k3-k4)<=eps) && (abs(k4-k1)<=eps));
	}
}
int main() {
	fin = fopen("xumingshi.in", "r");
	fout = fopen("xumingshi.out", "w");
	fscanf(fin, "%d", &n);
	if(n <= 2) { fprintf(fout, "%d\n", n); exit(0); }
	for(int i = 1; i <= n; i++) {
		int a, b, c, d;
		fscanf(fin, "%d%d%d%d", &a, &b, &c, &d);
		nodes[i] = Node(a, b, c, d);
	}
	for(int i = 1; i <= n-2; i++) for(int j = i+1; j <= n-1; j++) {
		if(ans-2 > n-j) break;
		int tmp = 2;
		for(int k = j+1; k <= n; k++) if(isal(i, j, k)) tmp++;
		if(tmp > ans) ans = tmp;
	}
	fprintf(fout, "%d\n", ans);
	return 0;
}