Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:哪个大侠给看看,第一次做DFS

Posted by 623246339 at 2016-08-06 11:05:10 on Problem 1118
In Reply To:哪个大侠给看看,第一次做DFS Posted by:Liuzhaoliang at 2008-07-02 18:37:54
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator