Problem:


		
Problem D: Area Separation

		

			Mr. Yamada Springfield Tanaka は、国家区画整理事業局局長補佐代理という大任を任されていた。
			現在、彼の国は大規模な区画整理の最中であり、この区画整理をスムーズに終わらせることができたならば彼の昇進は間違いなしであるとされている。
		

		

			ところが、そんな彼の出世を快く思わない者も多くいるのだ。 そんな人間の 1 人に、Mr.Sato Seabreeze Suzuki がいた。
			彼は、ことあるごとに Mr. Yamada の足を引っ張ろうと画策してきた。 今回も Mr. Sato は足を引っ張るために、実際の区画整理を担当している組織に圧力をかけて、区画整理の結果を非常に分かりにくいものにしてしまった。
		

		

			そのため、Mr. Yamada に渡された結果は、 ある正方形の土地をどの直線で分割したかという情報のみになっていた。
			最低限、その正方形の土地がいくつに分割されたかだけでも分からなければ、Mr. Yamada は昇進どころか解雇されること間違いなしである。
		

		

			あなたの仕事は、(-100,-100)、(100,-100)、(100,100)、(-100,100) を頂点とする正方形領域が、与えられた n 本の直線によっていくつに分割されているかを調べるプログラムを書いて、Mr. Yamada を解雇の危機から救うことである。
		

		
Input

		

			入力は複数のテストケースからなる。
		

		

			それぞれのテストケースの最初の行では、直線数を表す整数 n が与えられる（1 <= n <= 100）。 その後の n 行にはそれぞれ 4 つの整数 x1 、y1 、 x2 、y2 が含まれる。
			これらの整数は直線上の相異なる 2 点 (x1 , y1 ) と (x2 , y2 ) を表す。
			与えられる 2 点は常に正方形の辺上の点であることが保証されている。 与えられる n 本の直線は互いに異なり、直線同士が重なることはない。 また、直線が正方形の辺と重なることもない。
		

		

			入力の終了は n = 0 で表される。
		

		
Output

			

				それぞれのテストケースについて、n 本の直線によって分割された領域の数を 1 行で出力せよ。
			

			

				なお、距離が 10-10 未満の 2 点は一致するとみなしてよい。 また、|PQ| < 10-10、|QR| < 10-10 でかつ |PR| >= 10-10となるような交点の組 P、Q、R は存在しない。
			

		
Sample Input

		

2
-100 -20 100 20
-20 -100 20 100
2
-100 -20 -20 -100
20 100 100 20
0

		
Output for the Sample Input

		

4
3



Sample input:
2
-100 -20 100 20
-20 -100 20 100
2
-100 -20 -20 -100
20 100 100 20
0


Sample output:
4
3

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from decimal import Decimal

def get_point(line1, line2):
    m1, k1 = line1
    m2, k2 = line2
    if m1 == m2:
        return None    
    elif m1 is None and m2 is None:
        return None
    elif m1 is None:
        x = k1
        y = m2 * x + k2
    elif m2 is None:
        x = k2
        y = m1 * x + k1
    else:
        x = (k2-k1)/(m2-m1)
        y = m1*x+k
    if -100 < x < 100 and -100 < y < 100:
        return (x, y)
    else:
        return None

while True:
    N = int(input())
    if not N:
        break
    lines = []
    for i in range(N):
        x1, y1, x2, y2 = [Decimal(int(i)) for i in input().split()]
        if x1 == x2:
            lines.append((None, x1))
        else:
            m = (y2-y1) / (x2-x1)
            k = y1 - m * x1
            lines.append((m, k))
    
    iterated_lines = []
    ans = 1
    for line1 in lines:
        pt_set = set()
        for line2 in iterated_lines:
            pt = get_point(line1, line2)
            # print(pt)
            if pt:
                pt_set.add(pt)
        ans += len(pt_set) + 1
        iterated_lines.append(line1)
    print(ans)

Submission status: Wrong Answer

Solution code:
def make_line(line_str):
    x1, y1, x2, y2 = map(int, line_str.split())
    return (x1 + 1j * y1, x2 + 1j * y2)


def cross_point(l1, l2):
    (p1, p2), (p3, p4) = l1, l2
    v34, v12, v23, v31 = p4 - p3, p2 - p1, p3 - p2, p1 - p3
    s1 = v34.real * v31.imag - v34.imag * v31.real
    s2 = v34.real * v23.imag - v34.imag * v23.real
    if s1 + s2 == 0:
        return None
    rt = s1 / (s1 + s2)
    cp = p1 + v12 * rt
    if abs(cp.real) >= 100 or abs(cp.imag) >= 100:
        return None
    return cp


while True:
    n = int(input())
    if not n: break
    lines = [make_line(input()) for _ in range(n)]

    crossed = set()
    for i, line in enumerate(lines):
        crossed.update(cross_point(line, l) for l in lines[:i])

    crossed.discard(None)
    print(1 + n + len(crossed))

Submission status: Wrong Answer

Solution code:
def make_line(line_str):
    x1, y1, x2, y2 = map(int, line_str.split())
    return (x1 + 1j * y1, x2 + 1j * y2)


def cross_point(l1, l2):
    (p1, p2), (p3, p4) = l1, l2
    v34, v12, v23, v31 = p4 - p3, p2 - p1, p3 - p2, p1 - p3
    s1 = v34.real * v31.imag - v34.imag * v31.real
    s2 = v34.real * v23.imag - v34.imag * v23.real
    if s1 + s2 == 0:
        return None
    rt = s1 / (s1 + s2)
    cp = p1 + v12 * rt
    if abs(cp.real) >= 100 or abs(cp.imag) >= 100:
        return None
    cp *= 1e10
    return (int(cp.real), int(cp.imag))


while True:
    n = int(input())
    if not n: break
    lines = [make_line(input()) for _ in range(n)]

    crossed = set()
    for i, line in enumerate(lines):
        crossed.update(cross_point(line, l) for l in lines[:i])

    crossed.discard(None)
    print(1 + n + len(crossed))

Submission status: Wrong Answer

Solution code:
def make_line(line_str):
    x1, y1, x2, y2 = map(int, line_str.split())
    return (x1 + 1j * y1, x2 + 1j * y2)


def cross_point(l1, l2):
    (p1, p2), (p3, p4) = l1, l2
    v34, v12, v23, v31 = p4 - p3, p2 - p1, p3 - p2, p1 - p3
    s1 = v34.real * v31.imag - v34.imag * v31.real
    s2 = v34.real * v23.imag - v34.imag * v23.real
    if s1 + s2 == 0:
        return None
    rt = s1 / (s1 + s2)
    if -1e-10 <= rt <= 1 + 1e-10:
        cp = (p1 + v12 * rt) * 1e10
        return (int(cp.real), int(cp.imag))
    else:
        return None


while True:
    n = int(input())
    if not n: break
    lines = [make_line(input()) for _ in range(n)]

    num_crossed = 0
    for i, line in enumerate(lines):
        crossed = set(cross_point(line, l) for l in lines[:i])
        crossed.discard(None)
        num_crossed += len(crossed)

    print(1 + n + num_crossed)

Submission status: Wrong Answer

Solution code:
def is_cross((x0, y0, x1, y1), (x2, y2, x3, y3)):
    dx0 = x1 - x0
    dy0 = y1 - y0
    dx1 = x3 - x2
    dy1 = y3 - y2

    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if s < 0:
        s = -s
        sm = -sm
    t = (y2-y0)*dx0 - (x2-x0)*dy0
    tm = dx1*dy0 - dy1*dx0
    if t < 0:
        t = -t
        tm = -tm
    return 0 <= s <= max(sm, 0) and 0 <= t <= max(tm, 0)

while 1:
    n = input()
    if n == 0:
        break
    ans = 1
    ls = []
    for i in xrange(n):
        e = map(int, raw_input().split())
        cnt = 0
        for l in ls:
            if is_cross(e, l):
                cnt += 1
        ls.append(e)
        ans += cnt+1
    print ans

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

while True:
    n = input()
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = map(int, raw_input().split())
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    ans = n + 1
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            #print l1, l2
            det = l1[0] * l2[1] - l1[1] * l2[0]
            #print det
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            #print x, y
            if x > -100 * det and x < 100 * det and y > -100 * det and y < 100 * det:
                ans += 1
    print ans

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                m[(x, y, det)] = 1
    print(1 + n + len(m))

Submission status: Accepted

Solution code:
def make_line(line_str):
    x1, y1, x2, y2 = map(int, line_str.split())
    return (x1 + 1j * y1, x2 + 1j * y2)


def cross_point(l1, l2):
    (p1, p2), (p3, p4) = l1, l2
    v34, v12, v23, v31 = p4 - p3, p2 - p1, p3 - p2, p1 - p3
    s1 = v34.real * v31.imag - v34.imag * v31.real
    s2 = v34.real * v23.imag - v34.imag * v23.real
    if s1 + s2 == 0:
        return None
    rt = s1 / (s1 + s2)
    cp = p1 + v12 * rt
    if abs(cp.real) >= 100 or abs(cp.imag) >= 100:
        return None
    cp *= 1e10
    return (int(cp.real), int(cp.imag))


while True:
    n = int(input())
    if not n: break
    lines = [make_line(input()) for _ in range(n)]

    num_crossed = 0
    for i, line in enumerate(lines):
        current_crossed = set(cross_point(line, l) for l in lines[:i])
        current_crossed.discard(None)
        num_crossed += len(current_crossed)

    print(1 + n + num_crossed)

Submission status: Accepted

Solution code:
def make_line(line_str):
    x1, y1, x2, y2 = map(int, line_str.split())
    return (x1 + 1j * y1, x2 + 1j * y2)


def cross_point(l1, l2):
    (p1, p2), (p3, p4) = l1, l2
    v34, v12, v23, v31 = p4 - p3, p2 - p1, p3 - p2, p1 - p3
    s1 = v34.real * v31.imag - v34.imag * v31.real
    s2 = v34.real * v23.imag - v34.imag * v23.real
    if s1 + s2 == 0:
        return None
    rt = s1 / (s1 + s2)
    if 0 < rt < 1:
        cp = (p1 + v12 * rt) * 1e10
        return (int(cp.real), int(cp.imag))
    else:
        return None


while True:
    n = int(input())
    if not n: break
    lines = [make_line(input()) for _ in range(n)]

    num_crossed = 0
    for i, line in enumerate(lines):
        crossed = set(cross_point(line, l) for l in lines[:i])
        crossed.discard(None)
        num_crossed += len(crossed)

    print(1 + n + num_crossed)

Submission status: Accepted

Solution code:
def cross((x0, y0, x1, y1), (x2, y2, x3, y3)):
    dx0 = x1 - x0
    dy0 = y1 - y0
    dx1 = x3 - x2
    dy1 = y3 - y2

    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if s < 0:
        s = -s
        sm = -sm
    t = (y2-y0)*dx0 - (x2-x0)*dy0
    tm = dx1*dy0 - dy1*dx0
    if t < 0:
        t = -t
        tm = -tm
    if 0 < s < max(sm, 0) and 0 < t < max(tm, 0):
        return (x0 + float(s*dx0)/sm, y0 + float(s*dy0)/sm)
    return None

from math import sqrt
def dist((x0, y0), (x1, y1)):
    return sqrt((x0 - x1)**2 + (y0 - y1)**2)

while 1:
    n = input()
    if n == 0:
        break
    ans = 1
    ls = []
    for i in xrange(n):
        e = map(int, raw_input().split())
        cnt = 0
        ps = []
        for l in ls:
            c = cross(e, l)
            if c is not None:
                for p in ps:
                    if dist(c, p) < 1e-10:
                        break
                else:
                    ps.append(c)
        ls.append(e)
        ans += len(ps)+1
    print ans

Submission status: Accepted

Solution code:
def make_line(line_str):
    x1, y1, x2, y2 = map(int, line_str.split())
    return (x1 + 1j * y1, x2 + 1j * y2)
 
 
def cross_point(l1, l2):
    (p1, p2), (p3, p4) = l1, l2
    v34, v12, v23, v31 = p4 - p3, p2 - p1, p3 - p2, p1 - p3
    s1 = v34.real * v31.imag - v34.imag * v31.real
    s2 = v34.real * v23.imag - v34.imag * v23.real
    if s1 + s2 == 0:
        return None
    rt = s1 / (s1 + s2)
    if 0 < rt < 1:
        cp = (p1 + v12 * rt) * 1e10
        return (int(cp.real), int(cp.imag))
    else:
        return None
 
 
while True:
    n = int(input())
    if not n: break
    lines = [make_line(input()) for _ in range(n)]
 
    num_crossed = 0
    for i, line in enumerate(lines):
        crossed = set(cross_point(line, l) for l in lines[:i])
        crossed.discard(None)
        num_crossed += len(crossed)
 
    print(1 + n + num_crossed)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    ans = n + 1
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                ans += 1
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                if (x, y, det) in m:
                    m[(x, y, det)] += 1
                else:
                    m[(x, y, det)] = 1
    for p in m:
        S = 0
        cnt = 0
        while True:
            S += cnt
            if m[p] == S:
                ans -= cnt * (cnt - 1) // 2
                break
            cnt += 1
    print(ans)

Submission status: Accepted

Solution code:
def _f(px, py, qx, qy, rx, ry):
    return (qx - px) * (ry - py) - (qy - py) * (rx - px)

def intersect(px, py, qx, qy, rx, ry, sx, sy):
    f1 = _f(px, py, qx, qy, rx, ry)
    f2 = _f(px, py, qx, qy, sx, sy)
    f3 = _f(rx, ry, sx, sy, px, py)
    f4 = _f(rx, ry, sx, sy, qx, qy)
    
    return f1 * f2 < 0 and f3 * f4 < 0

def intersection(px, py, qx, qy, rx, ry, sx, sy):
    det = (px - qx) * (sy - ry) - (sx - rx) * (py - qy)
    t = ((sy - ry) * (sx - qx) + (rx - sx) * (sy - qy)) / det
    
    x = t * px + (1 - t) * qx
    y = t * py + (1 - t) * qy
    
    return (x, y)

def solve():
    from sys import stdin
    f_i = stdin
    
    while True:
        n = int(f_i.readline())
        if n == 0:
            break
        
        area = 1
        segments = set()
        
        for i in range(n):
            px, py, qx, qy = map(int, f_i.readline().split())
            points = set()
            cnt = 1
            
            for rx, ry, sx, sy in segments:
                if intersect(px, py, qx, qy, rx, ry, sx, sy):
                    ip = intersection(px, py, qx, qy, rx, ry, sx, sy)
                    if ip not in points:
                        cnt += 1
                        points.add(ip)
                        
            segments.add((px, py, qx, qy))
            
            area += cnt
        
        print(area)

solve()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def intersection(a1, a2, b1, b2):
    x1,y1 = a1
    x2,y2 = a2
    x3,y3 = b1
    x4,y4 = b2

    ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1)
    eta = (x2 - x1) * (y4 - y1) - (y2 - y1) * (x4 - x1)
    delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3)
    if delta == 0:
        return None
    ramda = ksi / delta;
    mu = eta / delta;
    if ramda >= 0 and ramda <= 1 and mu >= 0 and mu <= 1:
        return (round(x1 + ramda * (x2 - x1), 9), round(y1 + ramda * (y2 - y1), 9))

    return None

def main():
    rr = []

    def f(n):
        def _f(l):
            return [(l[0],l[1]), (l[2],l[3])]
        a = [_f(LI()) for _ in range(n)]
        r = 1 + n
        itc = collections.defaultdict(int)
        for i in range(n):
            a1,a2 = a[i]
            for j in range(i+1,n):
                it = intersection(a1,a2,a[j][0],a[j][1])
                if not it:
                    continue
                if max(it) == 100 or min(it) == -100:
                    continue
                itc[it] += 1

        # print('itc',itc)

        for v in itc.values():
            if v <= 1:
                r += v
                continue
            for i in range(101):
                if v == i * (i+1) / 2:
                    r += i
                    break

        return r

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str,rr))


print(main())

Submission status: Accepted

Solution code:
import math

EPS = 1e-10

def eq(a, b):
  return (abs(a-b) < EPS)

def eqv(a, b):
  return (eq(a.real, b.real) and eq(a.imag, b.imag))

def cross(a, b):
  return a.real * b.imag - a.imag * b.real

def is_intersected_ls(a1, a2, b1, b2):
  return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) and \
         (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS)

def intersection_l(a1, a2, b1, b2):
  a = a2 - a1
  b = b2 - b1
  return a1 + a * cross(b, b1-a1) / cross(b, a)

while True:
  n = int(input())
  if n==0:
    break
  lines = []
  for _ in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    lines.append((complex(x1, y1), complex(x2, y2)))

  ans = 2
  for i in range(1, n):
    cross_point = []
    for j in range(0, i):
      l1, l2 = lines[i], lines[j]
      if is_intersected_ls(l1[0], l1[1], l2[0], l2[1]):
        p = intersection_l(l1[0], l1[1], l2[0], l2[1])
        if -100+EPS<=p.real<=100-EPS and -100+EPS<=p.imag<=100-EPS:
          cross_point.append(p)
    cnt = min(len(cross_point), 1)
    for i in range(1, len(cross_point)):
      flag = 0
      for j in range(0, i):
        if eqv(cross_point[i], cross_point[j]):
          flag = 1
      if not flag:
        cnt+=1
    ans += 1+cnt
  
  print(ans)

Submission status: Runtime Error

Solution code:
from itertools import combinations
from decimal import Decimal

def get_point(line1, line2):
    m1, k1 = line1
    m2, k2 = line2
    if m1 == m2:
        return None    
    elif m1 is None and m2 is None:
        return None
    elif m1 is None:
        x = k1
        y = m2 * x + k2
    elif m2 is None:
        x = k2
        y = m1 * x + k1
    else:
        x = (k2-k1)/(m2-m1)
        y = m1*x+k
    return (x, y)

while True:
    N = int(input())
    if not N:
        break
    lines = []
    for i in range(N):
        x1, y1, x2, y2 = [Decimal(int(i)) for i in input().split()]
        if x1 == x2:
            lines.append(None, x1)
        else:
            m = (y2-y1) / (x2-x1)
            k = y1 - m * x1
            lines.append((m, k))
    
    iterated_lines = []
    ans = 1
    for line1 in lines:
        pt_set = set()
        for line2 in iterated_lines:
            pt = get_point(line1, line2)
            # print(pt)
            if pt:
                pt_set.add(pt)
        ans += len(pt_set) + 1
        iterated_lines.append(line1)
    print(ans)

Submission status: Runtime Error

Solution code:
from itertools import combinations
from decimal import Decimal

def get_point(line1, line2):
    m1, k1 = line1
    m2, k2 = line2
    if m1 == m2:
        return None    
    elif m1 is None and m2 is None:
        return None
    elif m1 is None:
        x = k1
        y = m2 * x + k2
    elif m2 is None:
        x = k2
        y = m1 * x + k1
    else:
        x = (k2-k1)/(m2-m1)
        y = m1*x+k
    if -100 < x < 100 and -100 < y < 100:
        return (x, y)
    else:
        return None

while True:
    N = int(input())
    if not N:
        break
    lines = []
    for i in range(N):
        x1, y1, x2, y2 = [Decimal(int(i)) for i in input().split()]
        if x1 == x2:
            lines.append(None, x1)
        else:
            m = (y2-y1) / (x2-x1)
            k = y1 - m * x1
            lines.append((m, k))
    
    iterated_lines = []
    ans = 1
    for line1 in lines:
        pt_set = set()
        for line2 in iterated_lines:
            pt = get_point(line1, line2)
            # print(pt)
            if pt:
                pt_set.add(pt)
        ans += len(pt_set) + 1
        iterated_lines.append(line1)
    print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                ans += 1
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                m[(x, y, det)] = 1
    print(1 + n + len(m))