結果

問題 No.321 (P,Q)-サンタと街の子供たち
コンテスト
ユーザー ckawatak
提出日時 2019-04-13 17:37:20
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 135 ms / 2,000 ms
+ 252µs
コード長 488 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 436 ms
コンパイル使用メモリ 96,228 KB
実行使用メモリ 84,992 KB
最終ジャッジ日時 2026-08-27 23:21:01
合計ジャッジ時間 7,593 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math

P,Q = list(map(int, input().split()))
N = int(input())

g = math.gcd(P,Q)

if g != 0:
    P = P // g
    Q = Q // g

count = 0    
for _ in range(N):
    x,y = list(map(int, input().split()))
    
    if g == 0:
        if x == 0 and y == 0:
            count = count + 1
        continue
        
    if x % g != 0 or y % g != 0:
        continue

    x = x // g
    y = y // g
    if (P+Q) % 2 == 0 and (x+y) % 2 != 0:
        continue

    count = count + 1

print(count)
0