結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー ああいい
提出日時 2022-03-02 12:07:20
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 553 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 81,736 KB
実行使用メモリ 76,320 KB
最終ジャッジ日時 2024-07-16 05:50:40
合計ジャッジ時間 4,903 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1 RE * 3
other AC * 6 WA * 10 RE * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

p,q = map(int,input().split())
N = int(input())

def gcd(a,b):
    if b == 0:return a
    while True:
        r =a % b
        a = b
        b = r
        if r == 0:return a
ans = 0
d = gcd(p,q)
if d != 0:
    p //= d
    q //= d
    if (p+q) % 2 == 0:
        flag = True
for _ in range(N):
    x,y = map(int,input().split())
    if d == 0:
        if x == 0 and y == 0:ans += 1
        continue
    if x % d == 0 and y % d == 0:
        x //= d
        y //= d
        if flag:
            if (x+y)% 2 == 0:ans+= 1
            else:ans += 1
print(ans)
0