結果

問題 No.849 yuki国の分割統治
ユーザー gew1fw
提出日時 2025-06-12 18:39:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 81,912 KB
実行使用メモリ 96,868 KB
最終ジャッジ日時 2025-06-12 18:40:14
合計ジャッジ時間 5,227 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c, d = map(int, input().split())
N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]

D = a * d - b * c
if D != 0:
    d_abs = abs(D)
    components = set()
    for x, y in points:
        # Calculate (-b*x + a*y) mod d_abs
        component = (-b * x + a * y) % d_abs
        components.add(component)
    print(len(components))
else:
    # Calculate the orthogonal component: b*x - a*y
    components = set()
    for x, y in points:
        component = b * x - a * y
        components.add(component)
    print(len(components))
0