/*

题意:给出n,m。

n表示给出的n个横坐标为1-n,y为0的坐标m表示以下有m个坐标,在横坐标上的点

向各个角度看,在可以看到最多的点在同一条直线上的点的做多值为横坐标这一点的值,最后各个

横坐标的值的和为多少

思路:由于m的值为枚举随意的两个点连成的直线,看在直线上的点有多少,看这条线和横坐标的值为

多少。是否是整值点。假设是就记录这个整值点的最大值

*/

#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e6 +5;

const double eps =1e-3;

int b[maxn];

struct Point

{

    double x,y;

    Point(double x=0,double y=0):x(x),y(y) {}

};

typedef Point Vector;

Vector operator - (Point A,Point B)

{

    return Vector(A.x-B.x,A.y-B.y);

}

Vector operator +(Vector A,Vector B)

{

    return Vector(A.x+B.x,A.y+B.y);

}

Vector operator * (Vector A,double p)

{

    return Vector(A.x*p,A.y*p);

}

double Cross(Vector A,Vector B)

{

    return A.x*B.y-A.y*B.x;

}

int dcmp(double x)

{

    if(fabs(x)<eps)  return 0;

    return x>eps?

1:-1;

}

struct Line

{

    Point p;

    Vector v;

};

int GetLineIntersection(Line L1,Line L2)

{

    if(dcmp(Cross(L1.v,L2.v))==0)

        return 0;

    Vector u=L1.p-L2.p;

    int t=Cross(L2.v,u)/Cross(L1.v,L2.v);

    Point answer;

    answer=L1.p+L1.v*t;

    int temp=(int)(answer.x+0.5);

    if(dcmp(answer.x)>0&&dcmp(answer.x-temp)==0&&dcmp(answer.y)==0&&temp<=1000000)

        return temp;

    return 0;

}

int main()

{

    int n,m;

    Point a[300];

    while(scanf("%d%d",&n,&m)!=EOF)

    {

        memset(b,0,sizeof(b));

        for(int i=0; i<m; i++)

            scanf("%lf%lf",&a[i].x,&a[i].y);

        Line ox;

        ox.p.x=0;

        ox.p.y=0;

        ox.v.x=1;

        ox.v.y=0;

        Line l1;

        for(int i=0; i<m; i++)

        {

            for(int j=i+1; j<m; j++)

            {

                int have=2;

                for(int k=j+1; k<m; k++)

                {

                    if(dcmp(Cross(a[i]-a[j],a[k]-a[j]))==0)

                        have++;

                }

                l1.p=a[i];

                l1.v=a[i]-a[j];

                int flag=GetLineIntersection(ox,l1);

                if(flag)

                {

                    a[299].x=flag;

                    a[299].y=0;

                    if(dcmp(Cross(a[i]-a[j],a[299]-a[j]))==0)

                    b[flag]=max(b[flag],have);

                }

            }

        }

        int sum=0;

        for(int i=1; i<=n; i++)

            if(b[i])

                sum+=b[i];

            else

                sum++;

        cout << sum << endl;

    }

    return 0;

}

codeforces 183B - Zoo的更多相关文章

  1. Codeforces Round #250 (Div. 1) B. The Child and Zoo 并查集

    B. The Child and Zoo Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/ ...

  2. Codeforces 437D The Child and Zoo(贪心+并查集)

    题目链接:Codeforces 437D The Child and Zoo 题目大意:小孩子去參观动物园,动物园分非常多个区,每一个区有若干种动物,拥有的动物种数作为该区的权值.然后有m条路,每条路 ...

  3. Codeforces 437D The Child and Zoo - 树分治 - 贪心 - 并查集 - 最大生成树

    Of course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The ...

  4. Codeforces Round #359 (Div. 2) B. Little Robber Girl's Zoo 水题

    B. Little Robber Girl's Zoo 题目连接: http://www.codeforces.com/contest/686/problem/B Description Little ...

  5. Codeforces 437D The Child and Zoo(并查集)

    Codeforces 437D The Child and Zoo 题目大意: 有一张连通图,每个点有对应的值.定义从p点走向q点的其中一条路径的花费为途径点的最小值.定义f(p,q)为从点p走向点q ...

  6. Codeforces Round#250 D. The Child and Zoo(并差集)

    题目链接:http://codeforces.com/problemset/problem/437/D 思路:并差集应用,先对所有的边从大到小排序,然后枚举边的时候,如果某条边的两个顶点不在同一个集合 ...

  7. Codeforces 437 D. The Child and Zoo 并查集

    题目链接:D. The Child and Zoo 题意: 题意比较难懂,是指给出n个点并给出这些点的权值,再给出m条边.每条边的权值为该条路连接的两个区中权值较小的一个.如果两个区没有直接连接,那么 ...

  8. Codeforces D - The Child and Zoo

    D - The Child and Zoo 思路: 并查集+贪心 每条边的权值可以用min(a[u],a[v])来表示,然后按边的权值从大到小排序 然后用并查集从大的边开始合并,因为你要合并的这两个联 ...

  9. Codeforces Round #250 (Div. 2) D. The Child and Zoo 并查集

    D. The Child and Zoo time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

随机推荐

  1. RxJava 1.x 理解-3

    在 RxJava 1.x 理解-1 中,我们说到了RxJava的简单用法,但是这还远远不够,因为 输入的数据 ---> 被监听者(订阅源)对这些数据进行操作,或者执行响应的处理 --> 产 ...

  2. acitivity 和fragment 通信,使用广播来传递信息的问题

    使用广播来传递信息时 如果 acitivity  给 太快给 fragment  发送广播,fragment 收不到 使用回调的方式来解决

  3. C++类的复习

    1.C++ 类的声明:class class_name{    private:        /*        *私有的数据和成员函数        *只能被本类中的成员函数引用,类外不能调用   ...

  4. mysql-root本地无法登录处理

    主要有以下几种情况: 1.忘记密码 2.丢失root对localhost的访问权限或者对应的host授权 解决方案: ----------------------------------------- ...

  5. [JQuery]用InsertAfter实现图片走马灯展示效果

    写在前面 最近一个搞美工的朋友让我给他写一个图片轮播的特效. 需求: 图片向左循环滚动. 图片滚动到中间高亮显示,并在下方显示照片人物对应的信息. 鼠标悬停止滚动. 鼠标离开开始滚动. 单击图片,图片 ...

  6. XAMPP安装与多虚拟目录地址设置

    前端开发集成环境-XAMPP 在前端开发中,经常需要进行请求的调试等都需要一个服务器环境,这时类似wamp.XAMPP就是我们最后的选择,集成apache.php.mysql等一应俱全,不需要去单独配 ...

  7. linux 逻辑卷管理 调整分区大小

    测试机各种报错,创建个目录都报错,df看了一下,发现VolGroup-lv_root 100%,虚拟磁盘满了,怎么办呢 1,解决过程 # df -h //查看分区 # umount /home //取 ...

  8. DL380 G6 BIOS刷新方法

    bios下载地址SP44873.exe (5.9 MB) http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.js ...

  9. CentOS7下nrpe3.0安装(转)

    本人菜鸟一枚,在学习nagios的时候碰到了很多问题,在网上找了很多相关的教程,都是老版本的,怎么装都不对,强迫症的我非要按装新版本,老版本的教程怎么搞都不行,只能自己研究了. 首先,下载nrpe3. ...

  10. 第十五章 MySQL 数据库

    学习要点:1.Web 数据库概述2.MySQL 的操作3.MySQL 常用函数4.SQL 语句详解5.phpMyadmin 一.Web数据库概述 现在,我们已经熟悉了PHP 的基础知识,这是我们想暂时 ...