結果

問題 No.849 yuki国の分割統治
ユーザー mkawa2mkawa2
提出日時 2019-07-06 21:05:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 563 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 45,312 KB
最終ジャッジ日時 2024-04-16 08:35:31
合計ジャッジ時間 11,564 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 33 ms
10,496 KB
testcase_02 AC 35 ms
10,496 KB
testcase_03 AC 31 ms
10,624 KB
testcase_04 AC 31 ms
10,496 KB
testcase_05 AC 32 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 433 ms
31,488 KB
testcase_08 AC 467 ms
39,040 KB
testcase_09 AC 504 ms
42,240 KB
testcase_10 AC 520 ms
44,032 KB
testcase_11 AC 438 ms
37,632 KB
testcase_12 AC 498 ms
41,600 KB
testcase_13 AC 546 ms
42,368 KB
testcase_14 AC 511 ms
42,752 KB
testcase_15 AC 441 ms
37,632 KB
testcase_16 AC 555 ms
45,312 KB
testcase_17 AC 508 ms
45,056 KB
testcase_18 AC 555 ms
45,312 KB
testcase_19 AC 544 ms
45,312 KB
testcase_20 AC 560 ms
45,184 KB
testcase_21 AC 505 ms
42,240 KB
testcase_22 AC 541 ms
45,312 KB
testcase_23 AC 537 ms
45,056 KB
testcase_24 AC 524 ms
45,184 KB
testcase_25 AC 563 ms
45,184 KB
testcase_26 AC 31 ms
10,752 KB
testcase_27 AC 31 ms
10,624 KB
testcase_28 AC 30 ms
10,880 KB
testcase_29 AC 31 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c, d = map(int, input().split())
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
# 横移動
if a == c == 0:
    while b > 0:
        d, b = b, d % b
else:
    if a < c:
        a, b, c, d = c, d, a, b
    while c > 0:
        r = a // c
        a, b, c, d = c, d, a - r * c, b - r * d
    d = abs(d)
    nxy = []
    for x, y in xy:
        nxy.append([x % a, y - b * (x // a)])
    xy = nxy
ki = set()
# 縦移動
if d:
    for x, y in xy:
        ki.add((x, y % d))
else:
    for x, y in xy:
        ki.add((x, y))
print(len(ki))
0