結果

問題 No.186 中華風 (Easy)
ユーザー しらっ亭
提出日時 2015-08-10 23:26:55
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 415 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-17 13:31:40
合計ジャッジ時間 5,498 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd


def lcm(a, b):
    return a // gcd(a, b) * b


def solve():
    x1, y1 = list(map(int, input().split()))
    x2, y2 = list(map(int, input().split()))
    x3, y3 = list(map(int, input().split()))

    lcm12 = lcm(y1, y2)

    for a in range(y2 + 1):
        p = a * y1 + x1
        if p % y2 == x2:
            for b in range(1 if p == 0 else 0, y3 + 1):
                q = b * lcm12 + p
                if q % y3 == x3:
                    print(q)
                    return
            break
    print(-1)


if __name__ == '__main__':
    solve()
0