标签:
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Description
Input
Output
Sample Input
5 1 1 2 2 3 3 9 10 10 11 0
Sample Output
3
看注释
#include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; struct node { int x,y; }a[705]; int main() { int n,i,ans,j,f,m; while(scanf("%d",&n)!=EOF&&n!=0) { for(i=1;i<=n;i++) { scanf("%d%d",&a[i].x,&a[i].y); } ans=2; for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { //选择两点连成直线 f=2; for(m=j+1;m<=n;m++)//节约时间,避免重复验证 { if((a[m].x-a[i].x)*(a[m].y-a[j].y)==(a[m].x-a[j].x)*(a[m].y-a[i].y)) f++; } if(f>ans) ans=f; } } printf("%d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/Annetree/p/5830477.html