結果

問題 No.186 中華風 (Easy)
ユーザー しらっ亭しらっ亭
提出日時 2015-08-10 21:34:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 7,956 KB
最終ジャッジ日時 2023-09-27 00:47:57
合計ジャッジ時間 4,257 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
7,908 KB
testcase_01 AC 69 ms
7,916 KB
testcase_02 AC 75 ms
7,772 KB
testcase_03 AC 16 ms
7,772 KB
testcase_04 AC 147 ms
7,764 KB
testcase_05 AC 137 ms
7,900 KB
testcase_06 AC 212 ms
7,776 KB
testcase_07 AC 161 ms
7,784 KB
testcase_08 AC 250 ms
7,848 KB
testcase_09 AC 245 ms
7,912 KB
testcase_10 AC 258 ms
7,784 KB
testcase_11 AC 309 ms
7,904 KB
testcase_12 AC 84 ms
7,904 KB
testcase_13 AC 108 ms
7,956 KB
testcase_14 AC 115 ms
7,848 KB
testcase_15 AC 27 ms
7,844 KB
testcase_16 AC 72 ms
7,892 KB
testcase_17 AC 21 ms
7,812 KB
testcase_18 AC 48 ms
7,888 KB
testcase_19 AC 153 ms
7,844 KB
testcase_20 AC 57 ms
7,840 KB
testcase_21 AC 133 ms
7,844 KB
testcase_22 AC 148 ms
7,872 KB
権限があれば一括ダウンロードができます

ソースコード

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 + 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
    print(-1)


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