結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー fumofumofuni
提出日時 2021-09-14 01:23:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-06-26 03:32:22
合計ジャッジ時間 5,769 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
P,Q=map(int,input().split())
N=int(input())
res=0
if P+Q==0:
    for i in range(N):
        X,Y=map(int,input().split())
        if X==0 and Y==0:
            res+=1
    print(res)
    exit()
g=math.gcd(P,Q)
P//=g
Q//=g
for i in range(N):
    X,Y=map(int,input().split())
    X=abs(X)
    Y=abs(Y)
    if X%g==0 and Y%g==0:
        X//=g
        Y//=g
        if P%2 and Q%2:
            if (X+Y)%2==0:
                res+=1
        else:
            res+=1
print(res)


0