比赛 |
“Asm.Def战记之拉格朗日点”杯 |
评测结果 |
WWWWWWWWWW |
题目名称 |
Asm.Def找燃料 |
最终得分 |
0 |
用户昵称 |
sxysxy |
运行时间 |
0.020 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2015-11-04 10:17:50 |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
struct point
{
int x,y;
};
point pt[102];
struct oncefx
{
double k,b;
bool online(point &pt)
{
return fabs((double)pt.y - k*(pt.x)+b) < 0.0001;
}
};
int main()
{
freopen("asm_fuel.in", "r", stdin);
freopen("asm_fuel.out", "w", stdout);
int n;
int i,j,k;
int x1,y1;
int x2,y2;
int r = 0;
int ct;
double xielv;
double syx;
scanf("%d", &n);
if(n <= 2)
{
cout << n << endl;
return 0;
}
for(i = 1; i <= n; i++)
{
scanf("%d %d", &pt[i].x, &pt[i].y);
}
oncefx fx;
for(i = 1; i <= n; i++)
{
for(j = 1; j <= n; j++)
{
if(i == j)continue;
x1 = pt[i].x;
y1 = pt[i].y;
x2 = pt[j].x;
y2 = pt[j].y;
xielv = ((double)y2 - y1)/(x2 - x1);
syx = y2-xielv*x2;
fx.k = xielv;
fx.b = syx;
ct = 0;
for(k = 1; k <= n; k++)
if(fx.online(pt[k]))ct++;
r = max(r, ct);
}
}
cout << r << endl;
return 0;
}