結果
問題 |
No.186 中華風 (Easy)
|
ユーザー |
![]() |
提出日時 | 2016-05-15 13:36:27 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 685 ms / 2,000 ms |
コード長 | 837 bytes |
コンパイル時間 | 128 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-19 18:28:12 |
合計ジャッジ時間 | 8,015 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#!/usr/bin/env python3 import collections import math Equation = collections.namedtuple("Equation", "x y") NOSOL = -1 def lcm(a, b): return a // math.gcd(a, b) * b def solve(eq1, eq2, eq3): for i in range(eq2.y + 1): cand12 = eq1.x + eq1.y * i if cand12 > 0 and cand12 % eq2.y == eq2.x: sol12 = cand12 lcm12 = lcm(eq1.y, eq2.y) break else: return NOSOL for j in range(eq3.y + 2): cand123 = sol12 + lcm12 * j if cand123 > 0 and cand123 % eq3.y == eq3.x: return cand123 else: return NOSOL def main(): eq1 = Equation(*map(int, input().split())) eq2 = Equation(*map(int, input().split())) eq3 = Equation(*map(int, input().split())) print(solve(eq1, eq2, eq3)) if __name__ == '__main__': main()