| ||||||||||
| 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 | |||||||||
哪个大侠给看看,第一次做DFS#include <iostream>
#include <stdlib.h>
using namespace std;
int xy[700][2]={0};
int x[700]={0};
int best=0;
double currentk=0;
bool ok(int t)
{
double k=0;
int i;
for(i=t-1;i>0;i++)
if(x[i]==1)break;
if(i==0) return true;
else
{ if(xy[t][0]=xy[i][0]) k=10000;
else
k=((double)(xy[t][1]-xy[i][1]))/((double)(xy[t][0]-xy[i][0]));
if(currentk=0)currentk=k;
else if(x[t]==1&&k==currentk)return true;
else if(x[t]==0) return true;
return false;
}
}
void bt(int t,int n)
{
if(t>n)
{ int s=0;
for(int i=1;i<=n;i++)
if(x[i]==1)s++;
if(s>best)best=s;
}
else
if(t==1){currentk=0;best=0;}
for(int i=0;i<=1;i++)
{
x[t]=i;
if(ok(t))bt(t+1,n);
x[t]=0;
}
}
int main(int argc, char *argv[])
{
int m;
while(cin>>m,m)
{ for(int i=1;i<=m;i++)
cin>>xy[i][0]>>xy[i][1];
bt(1,m);
cout<<best<<endl;
best=0;currentk=0;
}
system("PAUSE");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator