結果
問題 | No.849 yuki国の分割統治 |
ユーザー | mkawa2 |
提出日時 | 2019-07-06 21:05:09 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 521 ms / 2,000 ms |
コード長 | 565 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 45,184 KB |
最終ジャッジ日時 | 2024-10-07 00:01:01 |
合計ジャッジ時間 | 10,653 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
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))