結果
問題 | No.849 yuki国の分割統治 |
ユーザー | maspy |
提出日時 | 2020-03-18 12:52:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 151 ms / 2,000 ms |
コード長 | 1,015 bytes |
コンパイル時間 | 178 ms |
コンパイル使用メモリ | 10,988 KB |
実行使用メモリ | 32,636 KB |
最終ジャッジ日時 | 2023-08-20 19:49:17 |
合計ジャッジ時間 | 6,569 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 13 ms
8,308 KB |
testcase_01 | AC | 13 ms
8,400 KB |
testcase_02 | AC | 14 ms
8,376 KB |
testcase_03 | AC | 13 ms
8,376 KB |
testcase_04 | AC | 13 ms
8,048 KB |
testcase_05 | AC | 14 ms
8,008 KB |
testcase_06 | AC | 13 ms
8,404 KB |
testcase_07 | AC | 136 ms
32,596 KB |
testcase_08 | AC | 119 ms
29,196 KB |
testcase_09 | AC | 136 ms
30,152 KB |
testcase_10 | AC | 141 ms
32,420 KB |
testcase_11 | AC | 115 ms
28,212 KB |
testcase_12 | AC | 132 ms
31,760 KB |
testcase_13 | AC | 145 ms
31,592 KB |
testcase_14 | AC | 136 ms
31,548 KB |
testcase_15 | AC | 113 ms
27,892 KB |
testcase_16 | AC | 147 ms
32,596 KB |
testcase_17 | AC | 138 ms
32,492 KB |
testcase_18 | AC | 145 ms
32,476 KB |
testcase_19 | AC | 148 ms
32,552 KB |
testcase_20 | AC | 151 ms
32,636 KB |
testcase_21 | AC | 131 ms
32,452 KB |
testcase_22 | AC | 150 ms
32,544 KB |
testcase_23 | AC | 143 ms
32,460 KB |
testcase_24 | AC | 141 ms
32,552 KB |
testcase_25 | AC | 147 ms
32,492 KB |
testcase_26 | AC | 13 ms
8,468 KB |
testcase_27 | AC | 14 ms
8,076 KB |
testcase_28 | AC | 13 ms
8,296 KB |
testcase_29 | AC | 13 ms
8,312 KB |
ソースコード
#!/usr/bin/env python3.8 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from math import gcd # %% a, b, c, d = map(int, readline().split()) N = int(readline()) m = map(int, read().split()) X, Y = zip(*zip(m, m)) # %% def fund_transform(a, b, c, d): while True: if a < c: a, c = c, a b, d = d, b if c == 0: if a == 0: b = abs(gcd(b, d)) d = 0 elif d == 0: pass else: d = abs(d) b %= d return a, b, c, d n = a // c a -= n * c b -= n * d def calc_key(x, y): if not a: y %= b return b * x + y n = x // a x -= a * n y -= b * n if not d: return a * y + x y %= d return a * y + x # %% a, b, c, d = fund_transform(a, b, c, d) keys = (calc_key(x, y) for x, y in zip(X, Y)) print(len(set(keys)))