結果
| 問題 | No.849 yuki国の分割統治 |
| ユーザー |
|
| 提出日時 | 2019-07-05 23:50:44 |
| 言語 | Python3 (3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 277 ms / 2,000 ms |
| + 798µs | |
| コード長 | 753 bytes |
| 記録 | |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 14,848 KB |
| 実行使用メモリ | 39,876 KB |
| 最終ジャッジ日時 | 2026-10-28 16:02:33 |
| 合計ジャッジ時間 | 7,994 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
#!/usr/bin/env python3
import math
def gcd2(a, b, c, d):
while a:
k = c // a
a, c = c - k * a, a
b, d = d - k * b, b
return a, b, c, d
def solve(a, b, c, d, n, p):
a, b, c, d = gcd2(a, b, c, d)
assert a == 0
found = set()
for x, y in p:
if c:
k = x // c
x1 = x - k * c
y1 = y - k * d
if b:
y1 %= b
else:
x1 = x
y1 = y % math.gcd(b, d)
found.add((x1, y1))
return len(found)
def main():
a, b, c, d = map(int, input().split())
n = int(input())
p = [tuple(map(int, input().split())) for _ in range(n)]
print(solve(a, b, c, d, n, p))
if __name__ == '__main__':
main()