結果

問題 No.186 中華風 (Easy)
ユーザー nebukuro09nebukuro09
提出日時 2017-01-17 13:48:36
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 6,504 KB
実行使用メモリ 7,856 KB
最終ジャッジ日時 2023-08-24 16:36:53
合計ジャッジ時間 5,088 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
7,668 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 114 ms
7,632 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 319 ms
7,632 KB
testcase_20 AC 89 ms
7,776 KB
testcase_21 AC 339 ms
7,732 KB
testcase_22 AC 213 ms
7,732 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 = False
for i in xrange(y2):
    a = x1 + (y1 * i)
    if a % y2 == x2:
        flag = True
        break
    
if flag:
    print -1
    exit()
    
b = None
for i in xrange(y3):
    b = a + (y1 * y2 * i)
    if b % y3 == x3:
        flag = True
        break
        
if flag:
    print -1
    exit()

print b if b > 0 else y1 * y2 * y3 / gec((gcd(y1, y2), y3))
0