結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー ああいいああいい
提出日時 2022-03-02 12:12:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 1,379 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 77,620 KB
最終ジャッジ日時 2023-09-23 05:58:15
合計ジャッジ時間 9,264 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,416 KB
testcase_01 AC 81 ms
71,392 KB
testcase_02 AC 84 ms
71,288 KB
testcase_03 AC 80 ms
71,280 KB
testcase_04 AC 81 ms
71,368 KB
testcase_05 AC 84 ms
71,208 KB
testcase_06 AC 81 ms
71,388 KB
testcase_07 AC 80 ms
71,236 KB
testcase_08 AC 81 ms
71,352 KB
testcase_09 AC 80 ms
71,072 KB
testcase_10 AC 79 ms
71,068 KB
testcase_11 AC 79 ms
71,228 KB
testcase_12 AC 80 ms
71,304 KB
testcase_13 AC 85 ms
71,356 KB
testcase_14 AC 142 ms
77,356 KB
testcase_15 AC 151 ms
77,304 KB
testcase_16 AC 123 ms
77,212 KB
testcase_17 AC 83 ms
71,416 KB
testcase_18 AC 130 ms
77,524 KB
testcase_19 AC 139 ms
77,432 KB
testcase_20 AC 152 ms
77,388 KB
testcase_21 AC 133 ms
77,108 KB
testcase_22 AC 114 ms
77,516 KB
testcase_23 AC 142 ms
77,472 KB
testcase_24 AC 124 ms
77,332 KB
testcase_25 AC 130 ms
77,404 KB
testcase_26 AC 151 ms
77,376 KB
testcase_27 AC 142 ms
77,620 KB
testcase_28 AC 142 ms
77,276 KB
testcase_29 AC 152 ms
77,280 KB
testcase_30 AC 105 ms
76,992 KB
testcase_31 AC 89 ms
71,092 KB
testcase_32 AC 125 ms
77,312 KB
testcase_33 AC 130 ms
77,384 KB
testcase_34 AC 122 ms
77,564 KB
testcase_35 AC 142 ms
77,376 KB
testcase_36 AC 107 ms
77,052 KB
testcase_37 AC 135 ms
77,360 KB
testcase_38 AC 128 ms
77,608 KB
testcase_39 AC 119 ms
77,536 KB
testcase_40 AC 158 ms
77,348 KB
testcase_41 AC 125 ms
77,420 KB
testcase_42 AC 146 ms
77,504 KB
testcase_43 AC 125 ms
77,136 KB
testcase_44 AC 140 ms
77,620 KB
権限があれば一括ダウンロードができます

ソースコード

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)
flag = False
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