結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,108 KB
testcase_01 AC 30 ms
10,108 KB
testcase_02 AC 31 ms
10,112 KB
testcase_03 AC 27 ms
10,108 KB
testcase_04 AC 27 ms
10,108 KB
testcase_05 AC 27 ms
10,112 KB
testcase_06 AC 27 ms
10,104 KB
testcase_07 WA -
testcase_08 AC 193 ms
28,216 KB
testcase_09 AC 199 ms
27,312 KB
testcase_10 AC 212 ms
25,124 KB
testcase_11 AC 187 ms
26,120 KB
testcase_12 AC 202 ms
24,156 KB
testcase_13 AC 211 ms
28,228 KB
testcase_14 AC 206 ms
25,636 KB
testcase_15 AC 187 ms
27,288 KB
testcase_16 AC 222 ms
34,652 KB
testcase_17 AC 218 ms
23,364 KB
testcase_18 AC 222 ms
34,104 KB
testcase_19 AC 220 ms
25,704 KB
testcase_20 AC 237 ms
30,936 KB
testcase_21 AC 196 ms
23,512 KB
testcase_22 AC 235 ms
32,520 KB
testcase_23 AC 233 ms
31,464 KB
testcase_24 AC 218 ms
25,176 KB
testcase_25 AC 225 ms
39,320 KB
testcase_26 AC 28 ms
10,104 KB
testcase_27 AC 27 ms
10,104 KB
testcase_28 AC 26 ms
10,104 KB
testcase_29 AC 27 ms
10,104 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:
    gAC = gcd(A, C)
    gBD = gcd(B, D)

    if not gAC:
        for X, Y in XY:
            st.add((X, 0))
    elif not gBD:
        for X, Y in XY:
            st.add((0, Y))
    else:
        for X, Y in XY:
            M = min(X // gAC, Y // gBD)
            st.add((X - M * gAC, Y - M * gBD))
print(len(st))
0