結果

問題 No.186 中華風 (Easy)
ユーザー nebukuro09nebukuro09
提出日時 2017-01-17 14:12:32
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,000 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 6,676 KB
実行使用メモリ 7,804 KB
最終ジャッジ日時 2023-09-27 00:50:55
合計ジャッジ時間 11,355 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 829 ms
7,632 KB
testcase_01 AC 182 ms
7,644 KB
testcase_02 AC 366 ms
7,644 KB
testcase_03 AC 25 ms
7,680 KB
testcase_04 AC 403 ms
7,564 KB
testcase_05 AC 427 ms
7,564 KB
testcase_06 AC 895 ms
7,796 KB
testcase_07 AC 383 ms
7,792 KB
testcase_08 AC 643 ms
7,676 KB
testcase_09 AC 617 ms
7,644 KB
testcase_10 AC 1,000 ms
7,772 KB
testcase_11 AC 840 ms
7,728 KB
testcase_12 AC 158 ms
7,804 KB
testcase_13 AC 522 ms
7,604 KB
testcase_14 AC 226 ms
7,564 KB
testcase_15 AC 61 ms
7,608 KB
testcase_16 AC 23 ms
7,728 KB
testcase_17 AC 23 ms
7,568 KB
testcase_18 AC 189 ms
7,784 KB
testcase_19 AC 207 ms
7,616 KB
testcase_20 AC 78 ms
7,676 KB
testcase_21 AC 181 ms
7,804 KB
testcase_22 AC 201 ms
7,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import gcd

x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
x3, y3 = map(int, raw_input().split())

flag = True
for i in xrange(y2):
    a = x1 + (y1 * i)
    if a % y2 == x2:
        flag = False
        break
    
if flag:
    print -1
    exit()

flag = True
for i in xrange(y3):
    b = a + (y1 * y2 / gcd(y1, y2) * i)
    if b % y3 == x3:
        flag = False
        break
        
if flag:
    print -1
    exit()

print b if b > 0 else min(x1, x2, x3) + y1 * y2 * y3 / (gcd(y1, y2) * gcd(y1*y2, y3))
0