結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー tassei903tassei903
提出日時 2023-08-05 10:54:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,066 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-04-23 08:14:10
合計ジャッジ時間 5,248 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,736 KB
testcase_01 AC 33 ms
52,480 KB
testcase_02 AC 34 ms
52,480 KB
testcase_03 AC 33 ms
52,480 KB
testcase_04 AC 32 ms
52,096 KB
testcase_05 AC 32 ms
52,480 KB
testcase_06 AC 32 ms
52,416 KB
testcase_07 AC 33 ms
52,480 KB
testcase_08 AC 35 ms
52,608 KB
testcase_09 AC 32 ms
52,736 KB
testcase_10 AC 32 ms
52,480 KB
testcase_11 AC 32 ms
51,968 KB
testcase_12 AC 31 ms
52,352 KB
testcase_13 AC 31 ms
52,480 KB
testcase_14 AC 72 ms
76,160 KB
testcase_15 AC 79 ms
76,288 KB
testcase_16 AC 66 ms
76,032 KB
testcase_17 AC 35 ms
52,864 KB
testcase_18 AC 69 ms
76,296 KB
testcase_19 AC 70 ms
76,544 KB
testcase_20 AC 83 ms
76,928 KB
testcase_21 AC 68 ms
76,032 KB
testcase_22 AC 58 ms
76,492 KB
testcase_23 AC 75 ms
76,544 KB
testcase_24 AC 68 ms
76,156 KB
testcase_25 AC 76 ms
76,160 KB
testcase_26 AC 83 ms
76,168 KB
testcase_27 AC 73 ms
75,904 KB
testcase_28 AC 77 ms
76,160 KB
testcase_29 AC 80 ms
76,140 KB
testcase_30 AC 47 ms
65,920 KB
testcase_31 AC 40 ms
60,544 KB
testcase_32 AC 66 ms
76,060 KB
testcase_33 AC 68 ms
76,092 KB
testcase_34 AC 65 ms
76,672 KB
testcase_35 AC 77 ms
75,904 KB
testcase_36 AC 48 ms
67,504 KB
testcase_37 AC 73 ms
76,152 KB
testcase_38 AC 71 ms
76,288 KB
testcase_39 AC 59 ms
76,160 KB
testcase_40 AC 85 ms
76,188 KB
testcase_41 AC 62 ms
76,504 KB
testcase_42 AC 78 ms
76,160 KB
testcase_43 AC 68 ms
76,400 KB
testcase_44 AC 77 ms
76,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
def norm(a):
    return a[0]*a[0]+a[1]*a[1]

def round(a, b):
    return (a*2+b)//(2*b)

def div(a, b):
    c = (round(a[0]*b[0] + a[1]*b[1], norm(b)), round(a[1]*b[0]-a[0]*b[1], norm(b)))
    return a[0] - b[0]*c[0] + b[1]*c[1], a[1] - b[0]*c[1] - b[1]*c[0]

def gcd(a, b):
    if b == (0,0):
        return a
    return gcd(b, div(a, b))


p, q = na()
if p == 0 and q == 0:
    n = ni()
    ans = 0
    for i in range(n):
        x, y = na()
        if x == 0 and y == 0:
            ans += 1
    print(ans)
    exit()

r = gcd((p, q), (p, -q))
n = ni()
ans = 0
for _ in range(n):
    x, y = na()
    if (r[0] * x + r[1] * y) % norm(r) == 0 and (r[0] * y - r[1] * x) % norm(r) == 0:
        ans += 1
print(ans)
0