結果

問題 No.186 中華風 (Easy)
ユーザー nebukuro09nebukuro09
提出日時 2017-01-17 14:10:52
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 7,264 KB
実行使用メモリ 7,820 KB
最終ジャッジ日時 2023-08-24 16:38:13
合計ジャッジ時間 11,128 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 826 ms
7,652 KB
testcase_01 AC 179 ms
7,800 KB
testcase_02 AC 363 ms
7,648 KB
testcase_03 AC 25 ms
7,636 KB
testcase_04 AC 398 ms
7,780 KB
testcase_05 AC 423 ms
7,708 KB
testcase_06 AC 890 ms
7,764 KB
testcase_07 AC 380 ms
7,608 KB
testcase_08 AC 639 ms
7,640 KB
testcase_09 AC 615 ms
7,652 KB
testcase_10 AC 995 ms
7,660 KB
testcase_11 AC 833 ms
7,820 KB
testcase_12 AC 156 ms
7,716 KB
testcase_13 AC 524 ms
7,772 KB
testcase_14 AC 222 ms
7,660 KB
testcase_15 AC 59 ms
7,636 KB
testcase_16 AC 22 ms
7,612 KB
testcase_17 WA -
testcase_18 AC 189 ms
7,764 KB
testcase_19 AC 207 ms
7,716 KB
testcase_20 AC 77 ms
7,800 KB
testcase_21 AC 180 ms
7,712 KB
testcase_22 AC 199 ms
7,764 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(gcd(y1, y2), y3))
0