結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー maspymaspy
提出日時 2020-03-04 18:45:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 34,000 KB
最終ジャッジ日時 2024-04-22 01:46:12
合計ジャッジ時間 4,242 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 29 ms
10,880 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 25 ms
10,880 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 25 ms
10,880 KB
testcase_09 AC 25 ms
10,752 KB
testcase_10 AC 26 ms
10,880 KB
testcase_11 AC 28 ms
10,752 KB
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 25 ms
10,624 KB
testcase_14 AC 84 ms
24,828 KB
testcase_15 AC 120 ms
34,000 KB
testcase_16 AC 59 ms
19,796 KB
testcase_17 AC 27 ms
10,752 KB
testcase_18 AC 68 ms
21,756 KB
testcase_19 AC 81 ms
25,608 KB
testcase_20 AC 112 ms
33,424 KB
testcase_21 AC 86 ms
24,004 KB
testcase_22 AC 41 ms
14,724 KB
testcase_23 AC 106 ms
30,012 KB
testcase_24 AC 44 ms
15,572 KB
testcase_25 AC 70 ms
23,508 KB
testcase_26 AC 104 ms
32,612 KB
testcase_27 AC 87 ms
27,188 KB
testcase_28 AC 88 ms
26,724 KB
testcase_29 AC 126 ms
33,872 KB
testcase_30 AC 28 ms
11,392 KB
testcase_31 AC 28 ms
11,008 KB
testcase_32 AC 75 ms
22,528 KB
testcase_33 AC 70 ms
22,056 KB
testcase_34 AC 56 ms
18,860 KB
testcase_35 AC 109 ms
28,396 KB
testcase_36 AC 28 ms
11,392 KB
testcase_37 AC 79 ms
24,656 KB
testcase_38 AC 70 ms
21,784 KB
testcase_39 AC 45 ms
13,940 KB
testcase_40 AC 113 ms
32,484 KB
testcase_41 AC 52 ms
16,284 KB
testcase_42 AC 97 ms
29,356 KB
testcase_43 AC 61 ms
19,740 KB
testcase_44 AC 90 ms
27,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from math import gcd

# %%
P, Q = map(int, readline().split())
N = int(readline())
m = map(int, read().split())
XY = list(zip(m, m))

# %%
d = gcd(P, Q)
if d == 0:
    answer = sum(x == y == 0 for x, y in XY)
    print(answer)
    exit()
P //= d
Q //= d
is_even = (P + Q) % 2 == 0


# %%
def check(X, Y, d, is_even):
    if X % d != 0:
        return False
    if Y % d != 0:
        return False
    X //= d
    Y //= d
    if is_even:
        return (X + Y) % 2 == 0
    else:
        return True


# %%
answer = sum(check(x, y, d, is_even) for x, y in XY)
print(answer)
0