結果
問題 | No.186 中華風 (Easy) |
ユーザー |
|
提出日時 | 2015-05-02 20:36:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 513 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-19 18:25:14 |
合計ジャッジ時間 | 1,646 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
from sys import stdin readline = stdin.readline def extended_gcd(x, y): if y == 0: return 1, 0, x a, b, c = extended_gcd(y, x % y) return b, a - x // y * b, c def chinese(xy): xx, yy = 0, 1 for x, y in xy: a, b, c = extended_gcd(yy, y) d, m = divmod(xx - x, c) if m: return -1 yy = yy * y // c xx = (y * d * b + x) % yy return xx if xx else yy xy = [list(map(int, readline().split())) for _ in range(3)] print(chinese(xy))