不知道为什么错。。

/*************************************************************************
> File Name: poj3429.cpp
> Author: zhengnanlee
> Mail: zhengnanlee@hotmail.com
> Created Time: 2013年09月21日 星期六 09时10分12秒
************************************************************************/

#include <iostream>
#include <math.h>

using namespace std;

#define eps 1e-5
#define zero(x) (((x)>0?(x):-(x))<eps)
#define LL double

struct point{ LL x, y; }p[105];

int parallel(point u1, point u2, point v1, point v2)
{
    return zero((u1.x - u2.x)*(v1.y - v2.y) - (v1.x - v2.x)*(u1.y - u2.y));
}

point intersection(point u1, point u2, point v1, point v2)
{
    point ret = u1;
    LL t = ((u1.x - v1.x)*(v1.y - v2.y) - (u1.y - v1.y)*(v1.x - v2.x)) / ((u1.x - u2.x)*(v1.y - v2.y) - (u1.y - u2.y)*(v1.x - v2.x));
    ret.x += (u2.x - u1.x)*t;
    ret.y += (u2.y - u1.y)*t;
    return ret;
}

double distance(point a)
{
    return sqrt(a.x * a.x + a.y * a.y);
}

int main()
{
    int N;
    cin >> N;
    int countt = N;
    for (int i = 1; i <= N; i++)
    {
        cin >> p[i].x >> p[i].y;
    }
    int M;
    cin >> M;
    int cnt = 0;
    for (int i = 0; i < M; i++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (!parallel(p[a], p[b], p[c], p[d]))
        {
            point temp = intersection(p[a], p[b], p[c], p[d]);
            p[++countt] = temp;
            if (zero(distance(temp))) cnt++;
        }
    }
    cout << cnt << endl;
}

poj3429(有错)的更多相关文章

  1. Windows 7上执行Cake 报错原因是Powershell 版本问题

    在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...

  2. 关于VS2015 ASP.NET MVC添加控制器的时候报错

    调试环境:VS2015 数据库Mysql  WIN10 在调试过程中出现类似下两图的同学们,注意啦. 其实也是在学习的过程中遇到这个问题的,找了很多资料都没有正面的解决添加控制器的时候报错的问题,还是 ...

  3. php报错 ----> Call to undefined function imagecreatetruecolor()

    刚才在写验证码的时候,发现报错,然后排查分析了一下,原来是所用的php版本(PHP/5.3.13)没有开启此扩展功能. 进入php.ini 找到extension=php_gd2.dll ,将其前面的 ...

  4. scp报错 -bash: scp: command not found

    环境:RHEL6.5 使用scp命令报错: [root@oradb23 media]# scp /etc/hosts oradb24:/etc/ -bash: scp: command not fou ...

  5. VS2015使用scanf报错的解决方案

    1.在程序最前面加: #define _CRT_SECURE_NO_DEPRECATE 2.在程序最前面加: #pragma warning(disable:4996) 3.把scanf改为scanf ...

  6. VS项目中使用Nuget还原包后编译生产还一直报错?

    Nuget官网下载Nuget项目包的命令地址:https://www.nuget.org/packages 今天就遇到一个比较奇葩的问题,折腾了很久终于搞定了: 问题是这样的:我的解决方案原本是好好的 ...

  7. Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误——SHH框架

    SHH框架工程,Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误 1.查看配置文件web.xml中是否配置.or ...

  8. mount报错: you must specify the filesystem type

    在linux mount /dev/vdb 到 /home 分区时报错: # mount /dev/vdb /homemount: you must specify the filesystem ty ...

  9. Android——eclipse下运行android项目报错 Conversion to Dalvik format failed with error 1解决

    在eclipse中导入android项目,项目正常没有任何错误,但是运行时候会报错,(clean什么的都没用了.....)如图: 百度大神大多说是jdk的问题,解决: 右键项目-Properties如 ...

随机推荐

  1. 使用LINQ来简化编程的7个技巧

    转载地址:http://www.cnblogs.com/lovecherry/archive/2008/05/23/1205565.html 自从学习LINQ以来,我发现了很多使用LINQ来改善代码的 ...

  2. 隐私模式启动IE 谷歌浏览器

    C:\Program Files (x86)\Internet Explorer\iexplore.exe -privateC:\Program Files (x86)\Google\Chrome\A ...

  3. LinearLayout的gravity属性以及其子元素的layout_gravity何时有效;RelativeLayout如何调整其子元素位置只能用子元素中的属性来控制,用RelativeLayout中的gravity无法控制!!!

    LinearLayout的gravity属性以及其子元素的layout_gravity何时有效:RelativeLayout如何调整其子元素位置只能用子元素中的属性来控制,用RelativeLayou ...

  4. CURL使用HTTPS的技术小结

    摘自http://www.51testing.com/html/14/175414-248202.html CURL使用HTTPS的技术小结 cURL是linux下命令行提交HTTP(S)请求的一个很 ...

  5. Linux学习笔记6-Linux根目录下各个目录的作用

    /bin:存放最常用命令:  /boot:启动Linux的核心文件: /dev:设备文件: /etc:存放各种配置文件: /home:用户主目录: /lib:系统最基本的动态链接共享库: /mnt:一 ...

  6. javascript中对条件推断语句的优化

    无论写什么程序,平时都会用到条件语句,如:if...else... switch这种语句,来达到对条件的推断. 以下看来一段代码: function abc(test){ if (test == 1) ...

  7. ADO.Net连接模式

    1.SqlConnection类 (1).通过构造函数创建一个SqlConnection对象,可以同时指定连接字符串 (2).通过SqlConnection对象的Open()方法打开数据库连接 (3) ...

  8. node.js querystring处理参数

    C:\Documents and Settings\Administrator\WebstormProjects\untitled6>node> url{ parse: [Function ...

  9. css3文本效果

    CSS3 包含多个新的文本特性. 在本章中,您将学到如下文本属性: 1. text-shadow 2. word-wrap 浏览器支持 Internet Explorer 10.Firefox.Chr ...

  10. HTML5 canvas 绘制精美的图形

    HTML5 是一个新兴标准,它正在以越来越快的速度替代久经考验的 HTML4.HTML5 是一个 W3C “工作草案” — 意味着它仍然处于开发阶段 — 它包含丰富的元素和属性,它们都支持现行的 HT ...