CF1036E.Covered Points

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given nn segments on a Cartesian plane. Each segment's endpoints have integer coordinates. Segments can intersect with each other. No two segments lie on the same line.

Count the number of distinct points with integer coordinates, which are covered by at least one segment.

输入格式

The first line contains a single integer nn ( 1n10001 \le n \le 1000 ) — the number of segments.

Each of the next nn lines contains four integers Axi,Ayi,Bxi,ByiAx_i, Ay_i, Bx_i, By_i ( 106Axi,Ayi,Bxi,Byi106-10^6 \le Ax_i, Ay_i, Bx_i, By_i \le 10^6 ) — the coordinates of the endpoints AA , BB ( ABA \ne B ) of the ii -th segment.

It is guaranteed that no two segments lie on the same line.

输出格式

Print a single integer — the number of distinct points with integer coordinates, which are covered by at least one segment.

输入输出样例

  • 输入#1

    9
    0 0 4 4
    -1 5 4 0
    4 0 4 4
    5 2 11 2
    6 1 6 7
    5 6 11 6
    10 1 10 7
    7 0 9 8
    10 -1 11 -1
    

    输出#1

    42
    
  • 输入#2

    4
    -1 2 1 2
    -1 0 1 0
    -1 0 0 3
    0 3 1 0
    

    输出#2

    7
    

说明/提示

The image for the first example:

Several key points are marked blue, the answer contains some non-marked points as well.

The image for the second example:

首页