結果

問題 No.849 yuki国の分割統治
ユーザー H3PO4H3PO4
提出日時 2021-02-25 12:17:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 11,856 KB
実行使用メモリ 40,104 KB
最終ジャッジ日時 2023-10-26 02:45:56
合計ジャッジ時間 7,703 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,100 KB
testcase_01 AC 27 ms
10,100 KB
testcase_02 AC 27 ms
10,104 KB
testcase_03 AC 27 ms
10,100 KB
testcase_04 AC 27 ms
10,100 KB
testcase_05 AC 27 ms
10,104 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 197 ms
28,212 KB
testcase_09 AC 200 ms
27,308 KB
testcase_10 AC 215 ms
25,120 KB
testcase_11 AC 188 ms
26,116 KB
testcase_12 AC 203 ms
24,152 KB
testcase_13 AC 212 ms
28,224 KB
testcase_14 AC 206 ms
25,632 KB
testcase_15 AC 186 ms
27,284 KB
testcase_16 AC 220 ms
34,660 KB
testcase_17 AC 220 ms
23,360 KB
testcase_18 AC 221 ms
34,100 KB
testcase_19 AC 224 ms
25,700 KB
testcase_20 AC 236 ms
30,932 KB
testcase_21 AC 199 ms
23,508 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 227 ms
39,316 KB
testcase_26 AC 28 ms
10,096 KB
testcase_27 AC 27 ms
10,096 KB
testcase_28 AC 27 ms
10,096 KB
testcase_29 AC 27 ms
10,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import gcd

input = sys.stdin.buffer.readline

A, B, C, D = map(int, input().split())
N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

det = A * D - B * C

st = set()
if det:
    for X, Y in XY:
        st.add(((D * X - C * Y) % det,
                (-B * X + A * Y) % det))
else:
    INF = 10 ** 9 + 5
    gAC = gcd(A, C)
    gBD = gcd(B, D)
    if not gAC: gAC = INF
    if not gBD: gBD = INF
    for X, Y in XY:
        st.add((X % gAC, X % gBD))
print(len(st))
0