結果

問題 No.849 yuki国の分割統治
ユーザー convexineq
提出日時 2019-07-05 22:12:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 878 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 43,216 KB
最終ジャッジ日時 2024-10-06 22:00:29
合計ジャッジ時間 8,348 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

from math import gcd

a,b,c,d = [int(i) for i in readline().split()]
n = int(input())
xy = [[int(i) for i in readline().split()] for _ in range(n)]


def heikouidou(x,y,pp,qq,g,h): #(e,f)に沿って(g,h)以上のぎりぎり
    m = (x*h-y*g)//(h*pp-g*qq)
    x -= m*pp
    y-= m*qq
    return (x,y)
    
    
    
if a*d == b*c:
    g = gcd(a,c)
#    print(a,b,c,d,g)
    assert b%g==0
    p,q = a//g, b//g
    s = set()
    for x,y in xy:
        s.add(heikouidou(x,y,p,q,-q,p))
    print(len(s))
#    print(s)
    exit()

        
s = set()
for x,y in xy:
#    print(x,y)
    x,y = heikouidou(x,y,a,b,c,d)
#    print(x,y)
    x,y = heikouidou(x,y,c,d,a,b)
#    print(x,y)
    s.add((x,y))
print(len(s))
#print(s)
exit()




         
0