結果

問題 No.849 yuki国の分割統治
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-12 11:11:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 92,872 KB
最終ジャッジ日時 2024-05-03 17:13:08
合計ジャッジ時間 5,725 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,608 KB
testcase_01 AC 41 ms
52,352 KB
testcase_02 AC 40 ms
52,864 KB
testcase_03 AC 39 ms
52,480 KB
testcase_04 AC 39 ms
52,608 KB
testcase_05 AC 38 ms
52,864 KB
testcase_06 AC 37 ms
52,608 KB
testcase_07 AC 140 ms
81,736 KB
testcase_08 AC 136 ms
84,556 KB
testcase_09 AC 137 ms
82,892 KB
testcase_10 AC 145 ms
81,768 KB
testcase_11 AC 133 ms
82,384 KB
testcase_12 AC 136 ms
81,244 KB
testcase_13 AC 143 ms
83,536 KB
testcase_14 AC 142 ms
82,256 KB
testcase_15 AC 133 ms
82,892 KB
testcase_16 AC 155 ms
91,344 KB
testcase_17 AC 141 ms
81,360 KB
testcase_18 AC 155 ms
90,396 KB
testcase_19 AC 142 ms
82,896 KB
testcase_20 AC 153 ms
86,984 KB
testcase_21 AC 134 ms
81,476 KB
testcase_22 AC 155 ms
88,908 KB
testcase_23 AC 162 ms
88,012 KB
testcase_24 AC 146 ms
81,608 KB
testcase_25 AC 152 ms
92,872 KB
testcase_26 AC 37 ms
51,968 KB
testcase_27 AC 37 ms
52,096 KB
testcase_28 AC 38 ms
52,096 KB
testcase_29 AC 37 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c, d  = map(int, input().split())
n = int(input())
XY = []
for i in range(n):
    x, y = map(int, input().split())
    XY.append((x, y))

import math
det = a*d-b*c
S = set()
if det == 0:
    g1 = math.gcd(a, c)
    g2 = math.gcd(b, d)
    for x, y in XY:
        if g1 != 0 and g2 != 0:
            q = min(x//g1, y//g2)
            x = x-q*g1
            y = y-q*g2
            S.add((x, y))
        elif g1 == 0:
            q = y//g2
            y = y-q*g2
            S.add((x, y))
        elif g2 == 0:
            q = x//g1
            x = x-q*g1
            S.add((x, y))
else:
    det = abs(det)
    S = set()
    for x, y in XY:
        z = (d*x-c*y)%det
        w = (-b*x+a*y)%det
        S.add((z, w))
print(len(S))
0