結果
問題 |
No.849 yuki国の分割統治
|
ユーザー |
![]() |
提出日時 | 2025-04-15 23:11:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,029 bytes |
コンパイル時間 | 401 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 97,116 KB |
最終ジャッジ日時 | 2025-04-15 23:13:13 |
合計ジャッジ時間 | 4,310 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 WA * 1 |
ソースコード
import sys import math def main(): a, b, c, d = map(int, sys.stdin.readline().split()) N = int(sys.stdin.readline()) points = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N)] determinant = a * d - b * c if determinant != 0: g = abs(determinant) groups = set() for x, y in points: s = (d * x - c * y) % g t = (-b * x + a * y) % g groups.add((s, t)) print(len(groups)) else: # Check if both vectors are zero vectors (but problem states they are not) # Since (a,b) and (c,d) are non-zero and parallel, compute based on (a,b) # Compute gcd of a and b g = math.gcd(a, b) if g == 0: g = math.gcd(c, d) a, b = c, d a_prime = a // g b_prime = b // g groups = set() for x, y in points: val = b_prime * x - a_prime * y groups.add(val) print(len(groups)) if __name__ == "__main__": main()