Poj Solution 1118

http://poj.org/problem?id=1118

//* @author: 82638882@163.com
import java.util.*;
public class Main
{
 public static void main(String[] args)
 {
  Scanner in=new Scanner(System.in);
  while(true)
  {    
   int a=in.nextInt();
   if(a==0)break;
    int[] arrx=new int[a];
    int[] arry=new int[a];
    for(int i=0;i< a;i++)
    {
        arrx[i]=in.nextInt();
        arry[i]=in.nextInt();
    }
    int max=0;
    for(int i=0;i< a-2;i++)
    {
        for(int j=i+1;j< a-1;j++)
        {
            int c=0;
            for(int u=j+1;u< a;u++)
            {
    if((arrx[i]-arrx[u])*(arry[i]-arry[j])==(arrx[i]-arrx[j])*(arry[i]-arry[u]))c++;
            }
            if(c>max)max=c;
        }
    }
    System.out.println(max+2);
    }
  }
}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *