結果

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

ソースコード

diff #

def gcd(a, b):
    m, n = min(a, b), max(a, b)

    while n != 0:
        m, n = n, m % n
    return m


def lcm(a, b):
    return a * b // gcd(a, 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):
        p = a * y1 + x1
        if p % y2 == x2:
            for b in range(1 if p == 0 else 0, y3):
                q = b * lcm12 + p
                if q % y3 == x3:
                    print(q)
                    return
    print(-1)


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