結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー 👑 rin204rin204
提出日時 2023-02-08 20:43:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 77,780 KB
最終ジャッジ日時 2023-09-20 10:56:12
合計ジャッジ時間 6,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,140 KB
testcase_01 AC 69 ms
71,420 KB
testcase_02 AC 73 ms
71,324 KB
testcase_03 AC 75 ms
71,408 KB
testcase_04 AC 70 ms
71,376 KB
testcase_05 AC 68 ms
71,424 KB
testcase_06 AC 72 ms
71,456 KB
testcase_07 AC 69 ms
71,512 KB
testcase_08 AC 71 ms
71,380 KB
testcase_09 AC 69 ms
71,624 KB
testcase_10 AC 69 ms
71,756 KB
testcase_11 AC 69 ms
71,556 KB
testcase_12 AC 70 ms
71,208 KB
testcase_13 AC 71 ms
71,324 KB
testcase_14 AC 125 ms
77,576 KB
testcase_15 AC 138 ms
77,564 KB
testcase_16 AC 111 ms
77,380 KB
testcase_17 AC 73 ms
71,496 KB
testcase_18 AC 117 ms
77,624 KB
testcase_19 AC 128 ms
77,780 KB
testcase_20 AC 139 ms
77,524 KB
testcase_21 AC 120 ms
77,604 KB
testcase_22 AC 102 ms
77,576 KB
testcase_23 AC 130 ms
77,516 KB
testcase_24 AC 106 ms
77,616 KB
testcase_25 AC 117 ms
77,208 KB
testcase_26 AC 136 ms
77,648 KB
testcase_27 AC 126 ms
77,412 KB
testcase_28 AC 126 ms
77,432 KB
testcase_29 AC 138 ms
77,524 KB
testcase_30 AC 98 ms
76,992 KB
testcase_31 AC 79 ms
71,568 KB
testcase_32 AC 116 ms
77,584 KB
testcase_33 AC 119 ms
77,604 KB
testcase_34 AC 112 ms
77,396 KB
testcase_35 AC 130 ms
77,504 KB
testcase_36 AC 91 ms
76,700 KB
testcase_37 AC 124 ms
77,740 KB
testcase_38 AC 117 ms
77,304 KB
testcase_39 AC 105 ms
77,652 KB
testcase_40 AC 138 ms
77,384 KB
testcase_41 AC 105 ms
77,664 KB
testcase_42 AC 132 ms
77,600 KB
testcase_43 AC 112 ms
77,496 KB
testcase_44 AC 130 ms
77,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

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

if p == 0 and q == 0:
    ans = 0
    n = int(input())
    for _ in range(n):
        x, y = map(int, input().split())
        if x == y == 0:
            ans += 1
    print(ans)
    exit()

g = gcd(p, q)
p //= g
q //= g
if (p + q) % 2 == 0:
    bi = True
else:
    bi = False
n = int(input())
ans = 0
for _ in range(n):
    x, y = map(int, input().split())
    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