HDU 1432 lining up (poj 1118)

Source: Internet
Author: User

Enumeration. The enumeration point complexity is n ^ 3.

You can also enumerate edge N * n * log (n ).


Poj 1118 must judge that 0 exits.


#include<cstdio>#include<cstring>#include<string>#include<queue>#include<algorithm>#include<map>#include<stack>#include<iostream>#include<list>#include<set>#include<vector>#include<cmath>#define INF 0x7fffffff#define eps 1e-8#define LL long long#define PI 3.141592654#define CLR(a,b) memset(a,b,sizeof(a))#define FOR(i,a,n) for(int i= a;i< n ;i++)#define FOR0(i,a,b) for(int i=a;i>=b;i--)#define pb push_back#define mp make_pair#define ft first#define sd second#define sf scanf#define pf printf#define acfun std::ios::sync_with_stdio(false)#define SIZE 700+1using namespace std;struct lx{    int x,y;}p[SIZE];int n;int main(){    while(~sf("%d",&n))    //while(~sf("%d",&n),n)    {        FOR(i,0,n)        sf("%d%d",&p[i].x,&p[i].y);        int ans=0;        int maxn=0;        FOR(i,0,n)        {            FOR(j,i+1,n)            {                maxn=0;                FOR(k,j+1,n)                {                    if((p[j].x-p[i].x)*(p[k].y-p[j].y)==(p[j].y-p[i].y)*(p[k].x-p[j].x))                        maxn++;                }                ans=max(maxn,ans);            }        }        pf("%d\n",ans+2);    }}


HDU 1432 lining up (poj 1118)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.