結果

問題 No.321 (P,Q)-サンタと街の子供たち
コンテスト
ユーザー ayaoni
提出日時 2020-11-26 19:30:27
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 471 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 229 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 81,024 KB
最終ジャッジ日時 2026-04-03 16:18:47
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
from math import gcd
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


P,Q = MI()
g = gcd(P,Q)

N = I()
ans = 0
for _ in range(N):
    X,Y = MI()
    if g == 0:
        if X == Y == 0:
            ans += 1
        continue
    if X % g == Y % g == 0:
        if (P//g+Q//g) % 2 == 0:
            if (X//g+Y//g) % 2 == 0:
                ans += 1
        else:
            ans += 1

print(ans)
0