結果

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

ソースコード

diff #

from math import gcd

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

if p == 0 or q == 0:
    ans = 0
    n = int(input())
    if p == 0 and q == 0:
        for _ in range(n):
            x, y = map(int, input().split())
            if x == y == 0:
                ans += 1
    print(ans)
    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