結果

問題 No.186 中華風 (Easy)
ユーザー nebukuro09nebukuro09
提出日時 2017-01-17 14:07:53
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 545 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 6,600 KB
実行使用メモリ 7,788 KB
最終ジャッジ日時 2023-08-24 16:37:47
合計ジャッジ時間 10,546 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 825 ms
7,628 KB
testcase_01 AC 179 ms
7,724 KB
testcase_02 AC 363 ms
7,728 KB
testcase_03 AC 26 ms
7,788 KB
testcase_04 AC 399 ms
7,656 KB
testcase_05 AC 423 ms
7,628 KB
testcase_06 AC 891 ms
7,724 KB
testcase_07 AC 384 ms
7,632 KB
testcase_08 AC 640 ms
7,628 KB
testcase_09 AC 614 ms
7,708 KB
testcase_10 AC 1,012 ms
7,708 KB
testcase_11 AC 834 ms
7,708 KB
testcase_12 AC 157 ms
7,704 KB
testcase_13 AC 519 ms
7,636 KB
testcase_14 AC 221 ms
7,704 KB
testcase_15 AC 59 ms
7,712 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 188 ms
7,632 KB
testcase_19 AC 205 ms
7,632 KB
testcase_20 AC 78 ms
7,780 KB
testcase_21 AC 180 ms
7,632 KB
testcase_22 AC 198 ms
7,628 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((gcd(y1, y2), y3))
0