不知道为什么错。。

/*************************************************************************
> 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. git 的一些使用和命令

    http://git.oschina.net/progit/2-Git-%E5%9F%BA%E7%A1%80.html(pro git)   git branch  (展示本地当前的所有分支,以及当前 ...

  2. bzoj3299 [USACO2011 Open]Corn Maze玉米迷宫

    Description 今年秋天,约翰带着奶牛们去玩玉米迷宫.迷宫可分成NxM个格子,有些格子种了玉 米,种宥玉米的格子无法通行.  迷宫的四条边界上都是种了玉米的格子,其屮只有一个格子 没种,那就是 ...

  3. 协方差cov

    摘录wiki如下(红色字体是特别标注的部分): http://zh.wikipedia.org/wiki/%E5%8D%8F%E6%96%B9%E5%B7%AE 协方差 协方差(Covariance) ...

  4. Monthly Expense(二分) 分类: 二分查找 2015-06-06 00:31 10人阅读 评论(0) 收藏

    Description Farmer John is an astounding accounting wizard and has realized he might run out of mone ...

  5. poj 1852 Ants_贪心

    题目大意:很多的蚂蚁都在长度为L(cm)的膀子上爬行,它们的速度都是1cm/s,到了棒子终端的时候,蚂蚁就会掉下去.如果在爬行途中遇到其他蚂蚁,两只蚂蚁的方向都会逆转.已知蚂蚁在棒子的最初位置坐标,但 ...

  6. 【每日一MOS】-RAC and Sequences (853652.1)

    序列有四种组合: a. CACHE + NOORDER b. CACHE + ORDER c. NOCACHE + NOORDER d. NOCACHE + ORDER 即使在单例配置下,当有大量的s ...

  7. UML的基本关联

     First, a dependency is a semantic relationship between two model elements in which a change to on ...

  8. ng-validate

    客户端表单验证是AngularJS里面最酷的功能之一. AngularJS表单验证可以让你从一开始就写出一个具有交互性和可相应的现代HTML5表单. 在AngularJS中,有许多表单验证指令.在这里 ...

  9. 将项目上传到bitbucket仓库

    先将项目添加git仓库中(本地) 成功后上门会有上传和下载按钮 提交代码:

  10. c#简单缓存使用,添加和修改

    private void SetCache(string CacheKey, object objObject, DateTime dt) { System.Web.Caching.Cache obj ...