結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー lloyzlloyz
提出日時 2023-10-26 07:29:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 85,948 KB
最終ジャッジ日時 2023-10-26 07:29:56
合計ジャッジ時間 8,058 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,652 KB
testcase_01 AC 34 ms
53,716 KB
testcase_02 AC 34 ms
53,716 KB
testcase_03 AC 34 ms
53,716 KB
testcase_04 AC 34 ms
53,716 KB
testcase_05 AC 35 ms
53,652 KB
testcase_06 AC 34 ms
53,716 KB
testcase_07 AC 35 ms
53,716 KB
testcase_08 AC 34 ms
53,716 KB
testcase_09 AC 34 ms
53,716 KB
testcase_10 AC 35 ms
53,716 KB
testcase_11 AC 34 ms
53,716 KB
testcase_12 AC 35 ms
53,716 KB
testcase_13 AC 35 ms
53,716 KB
testcase_14 AC 124 ms
82,612 KB
testcase_15 AC 149 ms
85,900 KB
testcase_16 AC 97 ms
78,724 KB
testcase_17 AC 51 ms
53,716 KB
testcase_18 AC 107 ms
80,464 KB
testcase_19 AC 121 ms
82,300 KB
testcase_20 AC 149 ms
85,948 KB
testcase_21 AC 112 ms
80,548 KB
testcase_22 AC 81 ms
76,876 KB
testcase_23 AC 133 ms
84,096 KB
testcase_24 AC 83 ms
76,912 KB
testcase_25 AC 110 ms
80,548 KB
testcase_26 AC 143 ms
84,192 KB
testcase_27 AC 125 ms
82,352 KB
testcase_28 AC 123 ms
82,332 KB
testcase_29 AC 145 ms
85,892 KB
testcase_30 AC 64 ms
71,120 KB
testcase_31 AC 47 ms
61,764 KB
testcase_32 AC 105 ms
80,488 KB
testcase_33 AC 108 ms
80,480 KB
testcase_34 AC 96 ms
78,704 KB
testcase_35 AC 127 ms
82,384 KB
testcase_36 AC 65 ms
71,108 KB
testcase_37 AC 114 ms
80,556 KB
testcase_38 AC 105 ms
80,468 KB
testcase_39 AC 77 ms
76,860 KB
testcase_40 AC 141 ms
84,180 KB
testcase_41 AC 87 ms
78,544 KB
testcase_42 AC 132 ms
84,084 KB
testcase_43 AC 97 ms
78,720 KB
testcase_44 AC 130 ms
82,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

p, q = map(int, input().split())
n = int(input())
P = [list(map(int, input().split())) for _ in range(n)]

ans = 0
if p == q == 0:
    for i in range(n):
        x, y = P[i]
        if x == y == 0:
            ans += 1
else:
    g = gcd(p, q)
    p //= g
    q //= g
    if (p + q) % 2 == 0:
        bi = True
    else:
        bi = False
    for i in range(n):
        x, y = P[i]
        if x % g != 0 or y % g != 0:
            continue
        x //= g
        y //= g
        if not bi or (x + y) % 2 == 0:
            ans += 1
print(ans)
0