結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー rlangevinrlangevin
提出日時 2023-10-26 12:29:32
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 386 bytes
コンパイル時間 1,219 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 76,336 KB
最終ジャッジ日時 2024-09-25 12:22:45
合計ジャッジ時間 5,703 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from math import gcd

P, Q = map(int, input().split())
g = gcd(P, Q)
P //= g
Q //= g
ans = 0
N = int(input())
for _ in range(N):
    X, Y = map(int, input().split())
    if X % g or Y % g:
        continue
    X //= g
    Y //= g
    if P % 2 == 0 or Q % 2 == 0:
        ans += 1
        continue
    if X % 2 == Y % 2:
        ans += 1

print(ans)
0