結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー ckawatak
提出日時 2019-04-13 17:37:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-09-15 11:13:15
合計ジャッジ時間 7,293 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

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