結果

問題 No.186 中華風 (Easy)
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-10 11:56:30
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 471 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 6,500 KB
実行使用メモリ 37,828 KB
最終ジャッジ日時 2023-09-19 09:40:17
合計ジャッジ時間 5,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
31,652 KB
testcase_01 AC 110 ms
26,804 KB
testcase_02 AC 89 ms
18,920 KB
testcase_03 AC 20 ms
10,492 KB
testcase_04 AC 194 ms
27,872 KB
testcase_05 AC 190 ms
31,536 KB
testcase_06 AC 259 ms
33,632 KB
testcase_07 AC 210 ms
33,076 KB
testcase_08 AC 322 ms
37,828 KB
testcase_09 AC 321 ms
37,632 KB
testcase_10 AC 260 ms
34,272 KB
testcase_11 AC 380 ms
37,640 KB
testcase_12 AC 124 ms
33,264 KB
testcase_13 AC 139 ms
24,664 KB
testcase_14 AC 151 ms
23,752 KB
testcase_15 AC 59 ms
27,708 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 90 ms
36,088 KB
testcase_19 AC 209 ms
37,380 KB
testcase_20 AC 71 ms
15,240 KB
testcase_21 AC 178 ms
32,936 KB
testcase_22 AC 201 ms
36,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(A,B):
    if B<A:
        return gcd(B,A)
    if B%A==0:
        return A
    return gcd(B%A,A)

X1,Y1=map(int,raw_input().split())
X2,Y2=map(int,raw_input().split())
X3,Y3=map(int,raw_input().split())

A1,B1=X1,Y1
for i in range(Y2):
    if A1%Y2==X2:
        break
    A1+=B1
if A1%Y2!=X2:
    print -1
    exit()
else:
    B1/=gcd(B1,Y2)
    B1*=Y2

for i in range(Y3):
    if A1%Y3==X3:
        break
    A1+=B1

if A1%Y3==X3:
    print A1
else:
    print -1
0