結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー 👑 rin204
提出日時 2023-02-08 20:42:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 82,024 KB
実行使用メモリ 76,748 KB
最終ジャッジ日時 2024-07-06 06:23:11
合計ジャッジ時間 4,226 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

p, q = map(int, input().split())

if p == 0 and q == 0:
    ans = 0
    n = int(input())
    for _ in range(n):
        x, y = map(int, input().split())
        if x == y == 0:
            ans += 1
    exit()

g = gcd(p, q)
p //= g
q //= g
if (p + q) % 2 == 0:
    bi = True
else:
    bi = False
n = int(input())
ans = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x % g != 0 or y % g != 0:
        continue
    x //= g
    y //= g
    if not bi or (x + y) % 2 == 0:
        ans += 1
print(ans)
0