結果
| 問題 |
No.849 yuki国の分割統治
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:17:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,029 bytes |
| コンパイル時間 | 514 ms |
| コンパイル使用メモリ | 82,100 KB |
| 実行使用メモリ | 97,264 KB |
| 最終ジャッジ日時 | 2025-04-15 23:19:05 |
| 合計ジャッジ時間 | 4,079 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()
lam6er