結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー rlangevinrlangevin
提出日時 2023-10-26 12:31:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 75,812 KB
最終ジャッジ日時 2023-10-26 12:31:26
合計ジャッジ時間 5,388 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,736 KB
testcase_01 AC 35 ms
53,736 KB
testcase_02 AC 36 ms
53,736 KB
testcase_03 AC 36 ms
53,736 KB
testcase_04 AC 34 ms
53,736 KB
testcase_05 AC 35 ms
53,736 KB
testcase_06 AC 35 ms
53,736 KB
testcase_07 AC 35 ms
53,736 KB
testcase_08 AC 36 ms
53,736 KB
testcase_09 AC 35 ms
53,736 KB
testcase_10 AC 35 ms
53,736 KB
testcase_11 AC 36 ms
53,736 KB
testcase_12 AC 35 ms
53,736 KB
testcase_13 AC 35 ms
53,736 KB
testcase_14 AC 68 ms
75,732 KB
testcase_15 AC 73 ms
75,620 KB
testcase_16 AC 59 ms
75,628 KB
testcase_17 AC 36 ms
53,740 KB
testcase_18 AC 63 ms
75,700 KB
testcase_19 AC 69 ms
75,812 KB
testcase_20 AC 77 ms
75,700 KB
testcase_21 AC 65 ms
75,628 KB
testcase_22 AC 50 ms
68,552 KB
testcase_23 AC 68 ms
75,620 KB
testcase_24 AC 52 ms
72,644 KB
testcase_25 AC 62 ms
75,620 KB
testcase_26 AC 74 ms
75,624 KB
testcase_27 AC 69 ms
75,740 KB
testcase_28 AC 68 ms
75,640 KB
testcase_29 AC 81 ms
75,620 KB
testcase_30 AC 44 ms
62,388 KB
testcase_31 AC 37 ms
53,740 KB
testcase_32 AC 61 ms
75,620 KB
testcase_33 AC 64 ms
75,732 KB
testcase_34 AC 60 ms
75,640 KB
testcase_35 AC 69 ms
75,632 KB
testcase_36 AC 43 ms
62,392 KB
testcase_37 AC 66 ms
75,636 KB
testcase_38 AC 63 ms
75,636 KB
testcase_39 AC 49 ms
68,544 KB
testcase_40 AC 78 ms
75,636 KB
testcase_41 AC 54 ms
72,644 KB
testcase_42 AC 69 ms
75,696 KB
testcase_43 AC 60 ms
75,632 KB
testcase_44 AC 69 ms
75,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from math import gcd

P, Q = map(int, input().split())
g = gcd(P, Q)
if g == 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()

P //= g
Q //= g
ans = 0
N = int(input())
for _ in range(N):
    X, Y = map(int, input().split())
    if X % g or Y % g:
        continue
    X //= g
    Y //= g
    if P % 2 == 0 or Q % 2 == 0:
        ans += 1
        continue
    if X % 2 == Y % 2:
        ans += 1

print(ans)
0