Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
高手一定要看啊,我都愁死了,虽然是N^3的,可就是wa,哪错了啊#include<iostream> using namespace std; struct rabbit { int x; int y; }; bool line(rabbit a,rabbit b,rabbit c) { if((b.x==a.x&&b.x==a.x)||(b.y==a.y&&b.y==c.y)) return true; if((b.y-a.y)*(c.x-a.x)==(c.y-a.y)*(b.x-a.x)) return true; else return false; } int main() { int max=0; rabbit rab[200]; int n=0; int i; int j,k,m; cin>>n; for(i=0;i<n;i++) { cin>>rab[i].x>>rab[i].y; } for(j=0;j<n-2;j++) { for(k=j+1;k<n-1;k++) { int max2=2; for(m=k+1;m<n;m++) { if(line(rab[j],rab[k],rab[m])) max2++; } if(max2>max) max=max2; } } cout<<max<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator