結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー H3PO4H3PO4
提出日時 2020-10-21 09:03:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 325 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 46,864 KB
最終ジャッジ日時 2023-09-28 14:05:45
合計ジャッジ時間 13,277 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
29,636 KB
testcase_01 AC 148 ms
29,780 KB
testcase_02 AC 138 ms
29,908 KB
testcase_03 AC 140 ms
29,752 KB
testcase_04 AC 168 ms
29,884 KB
testcase_05 AC 140 ms
29,748 KB
testcase_06 AC 144 ms
29,696 KB
testcase_07 AC 140 ms
29,700 KB
testcase_08 AC 146 ms
29,772 KB
testcase_09 AC 139 ms
29,852 KB
testcase_10 AC 134 ms
29,584 KB
testcase_11 AC 136 ms
29,780 KB
testcase_12 AC 145 ms
29,676 KB
testcase_13 AC 145 ms
29,736 KB
testcase_14 AC 238 ms
40,796 KB
testcase_15 AC 325 ms
46,864 KB
testcase_16 AC 195 ms
36,008 KB
testcase_17 AC 144 ms
29,660 KB
testcase_18 AC 207 ms
37,580 KB
testcase_19 AC 228 ms
40,956 KB
testcase_20 AC 278 ms
46,532 KB
testcase_21 AC 216 ms
39,400 KB
testcase_22 AC 159 ms
32,472 KB
testcase_23 AC 261 ms
43,888 KB
testcase_24 AC 170 ms
33,100 KB
testcase_25 AC 220 ms
38,836 KB
testcase_26 AC 270 ms
45,796 KB
testcase_27 AC 237 ms
42,000 KB
testcase_28 AC 238 ms
41,596 KB
testcase_29 AC 285 ms
46,784 KB
testcase_30 AC 142 ms
30,040 KB
testcase_31 AC 137 ms
29,900 KB
testcase_32 AC 206 ms
38,240 KB
testcase_33 AC 205 ms
37,788 KB
testcase_34 AC 184 ms
35,220 KB
testcase_35 AC 251 ms
42,936 KB
testcase_36 AC 140 ms
30,256 KB
testcase_37 AC 227 ms
40,044 KB
testcase_38 AC 205 ms
37,772 KB
testcase_39 AC 159 ms
32,192 KB
testcase_40 AC 280 ms
45,816 KB
testcase_41 AC 182 ms
33,480 KB
testcase_42 AC 259 ms
43,424 KB
testcase_43 AC 197 ms
36,172 KB
testcase_44 AC 243 ms
42,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
from math import gcd

input = sys.stdin.buffer.readline

P, Q = map(int, input().split())
N = int(input())
XY = np.array([tuple(map(int, input().split())) for _ in range(N)])
if (P, Q) == (0, 0):
    print(np.count_nonzero(np.all(XY == 0, axis=1)))
    exit()

g = gcd(P, Q)
P, Q = P // g, Q // g
XY = XY[np.all(XY % g == 0, axis=1)] // g
N = len(XY)

if (P + Q) % 2:
    print(N)
else:
    print(np.count_nonzero(np.sum(XY, axis=1) % 2 == 0))
0